Hello! First of all, thank you to anyone that took the time to read this.
I'm trying to have a user input information through a form. Once they press submit, the action: takes it to a functions.php page where it processes the information and inputs it into a database.
Then it redirects the user to the next part of the page (where they can upload a picture). However, I want to place the image location on the same row as the other info. Each row has a unique id that is NOT their UID (user id), so I can't use the $_SESSION['uid'] method.
So my question is... how do I get the unique rowid created from the first page form and use it on the third page (after processing the initial information through the second page) ?
Thank you!
edit: So i've seen that you can either do so using session variables or through hidden fields... which one is better? : x
and how are hidden fields used in this way?
Best,
Chris
Passing variables across two pages, one after another
Moderator: General Moderators
-
xpiamchris
- Forum Newbie
- Posts: 10
- Joined: Thu Jan 15, 2009 4:17 pm
Re: Passing variables across two pages, one after another
If your unique ID is autoincremented you can use myql_insert_id ( http://us.php.net/mysql_insert_id ) to get it. Then pass it to the third page. How you pass it depends on how you're getting to the third page. If you're doing a redirect, then use GET like
or of course you could use a session variable. As for a hidden field, you would need to do that in conjunction with submitting a form.
Code: Select all
header("Location: third_page.php?uid=12345");-
xpiamchris
- Forum Newbie
- Posts: 10
- Joined: Thu Jan 15, 2009 4:17 pm
Re: Passing variables across two pages, one after another
cool!
so i got the GET method to work, and it successfully passes... but how do you protect it so that other users are not able to go to any $GET_xx and change the data around?
so i got the GET method to work, and it successfully passes... but how do you protect it so that other users are not able to go to any $GET_xx and change the data around?
Re: Passing variables across two pages, one after another
If you need to hide the ID number, I would suggest passing it in a $_SESSION[] variable. You retrieve it just like a $_GET[].