No need to worry about passport control between Spain & France. Just hang on to the slip of paper the Spanish immigration agents give you upon entry, as you will need it when you depart (or so the slip of paper I received says; I hope I still have it
)
As for train or bus connections, look for connections to either Pamplona or San Sebastian. The Spanish train site is
http://www.renfe.es & the one bus site I know is
http://www.alsa.es . I´m sure others have another bus site, since there are many bus companies in Spain. A tip: take the bus when crossing the border, because if you take the train, you will sit at the border until a French train comes to pick you up.
From Pamplona, you can take the bus to Roncesvalles, then taxi to SJPdP. From San Sebastian, take the bus to Hendaye, then train to Bayonne. If you have the $ & the price is right, look for cheap flights to Biarritz (airport code BIQ), then take the bus or a taxi to Bayonne (they are very close together) to take the train to SJPdP.
Be prepared to spend the night somewhere before getting to SJPdP (in Pamplona, I can recommend the Hotel Eslava; inexpensive but very good)
Kelly