View Full Version : Adding to one database, grabbing info from another...help!

03-09-2010, 04:44 PM
Hi Guys,

I am going to try and make this as simple to understand as possible so that you guys can help me.

I have a form which a user enters their Email Address. When they click submit, it stores the email address into Database A and forwards them to the next page.

The second page has a form where they simply enter their Postcode, this then checks Database B and directs them to the final page which then has postcode specific information based on what they entered.

What I want to achieve is this....

One form which has Email field and Postcode field. When the user clicks submit it adds Email and Postcode to Database A but remembers their postcode, matches it with Database B and forwards them to the final postcode specific information page.

At the moment the only way I can do it is by making the user enter the postcode twice. Which is a bit of a waste of time on their part.

At the moment we are capturing emails but we would like to capture emails and their postcode.

Any ideas how this can be done???? We want to keep the email and postcode info stored in Database A and the other info stored in Database B we don't really want to merge the two Databases.

If you wizards could help that would be great!



03-09-2010, 04:55 PM
You could store the postcode as a SESSION variable



03-09-2010, 05:37 PM

Thanks Whizard.

I have had a look but I am a bit confused, I am very primitive when it comes to PHP which means I can just about do "Hello World". lol well not that bad.

Could you guide me in the steps I would need to do to make this session thing happen?


03-09-2010, 07:34 PM
A PHP SESSION is basically a server-side cookie. It can store information across page refreshes, just like with a normal cookie, but it is more secure since it is stored on the server. It's also a lot less complicated to get set up.

1. On every page where you want to be able to access the SESSION, you need to put this line before any output has been sent (echo/print statements, etc): session_start()

2. SESSION data can be accessed just like normal variables, like this:

$_SESSION['varName'] = "blahblahblah";
print $_SESSION['varName'];

So, you could store the postcode you received from the user in a session variable and then use it later, on a different page.

Hope that's helpful. If you have any more questions, just ask ;)

03-10-2010, 10:48 AM
Hi Whizard,

That is great, I understand now, many thanks for the help. I will attempt to put it into practice and will be back if I require further assistance.