The local trains from Cascais will take you into Lisbon's Cais do Sodre station. They run every every 10 - 20 minutes, journey 35 minutes or so.
From Cais do Sodre you make your way across town to Santa Apolonia station from where the trains to Porto leave about once every hour. Journey time is 3 to 3hrs 30 minutes depending on the train.
You can get all the times and fares in detail at www.cp.pt in English if you click on the little flag icon at the top next to where it says 'Acesso rapido'.
Be aware that seat reservation is compulsory on all Lisbon - Porto trains and it is a very busy line, so best reserve on-line if you can. Seat reservations open 30 days before travel. If you wait until the last moment to buy a ticket you might find all seats taken.
It's about 2.4km/1.5 miles between the two Lisbon stations. There's no direct metro (underground train) route but you can do it easily enough with one change of line.
I hope that helps.
Apart from the excellent previous reply, I'd like to add som info:
www.cp.pt is the portuguese ralway network, but for the timetable, look for Urbanos Lisboa, then, Cascais line/linha.
Once in Lisbon/Cais do Sodré, take the metro to Santa Apolonia (www.metrolisboa.pt).
The train will stop at Porto-Campanha, once there, to go to the city centre, you have two options: Take the metro (www.metrodoporto.pt) to wherever you need to go (moe or less) or take an urban train to the ao Bento station (www.cp.pt, then, urbanos Porto, any line.
I hope it helps.)