Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jul 2008
    Location
    Blackpool, UK
    Posts
    176
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Adding to one database, grabbing info from another...help!

    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!

    Cheers

    Dan

  • #2
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    You could store the postcode as a SESSION variable

    http://www.php.net/manual/en/intro.session.php

    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #3
    Regular Coder
    Join Date
    Jul 2008
    Location
    Blackpool, UK
    Posts
    176
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Hi

    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?


    Cheers

  • #4
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    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";
    -or-
    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
    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #5
    Regular Coder
    Join Date
    Jul 2008
    Location
    Blackpool, UK
    Posts
    176
    Thanks
    4
    Thanked 0 Times in 0 Posts
    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.


    Cheers

    Dan


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •