Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to pass parameters from one page to the next? 1

Status
Not open for further replies.

Apollo6

Technical User
Joined
Jan 27, 2000
Messages
418
Location
US
I have the following code where I execute a query on the first page. If it returns a certain value, I want to redirect to another page and pass along the parameters from the first page, else keep executing the first page.

Any help would be great. Please let me know if I have not included enought information to determine my problem.


//Supervisor Check...
$sup_query = "SELECT supervsr
FROM
emptable
WHERE
(((user_id)='$user_id'))";

$sup_result = pg_query($connection, $sup_query)
or die("Error in query: $sup_query.
" . pg_last_error($connection));
$sup_row = pg_fetch_row ($sup_result);
$sup_flag = $sup_row[0];
if ($sup_flag == 1) {
echo (&quot;<form name='SubMain' action='benefit_supervsr.org.php' method='post'>&quot;);
}
 
There are two ways to do it.

The first is through the use of a simulated GET-method form submission. In the case of your form, the action attribute would include something like:

<form name='SubMain' action='benefit_supervsr.org.php?thevariable=3' method='post'>

With PHP, this will work even if the form in question is a POST-method form -- PHP will happily accept GET- and POST- method input on the same submission.

Another way is through the use of session variables.

Want the best answers? Ask the best questions: TANSTAAFL!
 
No luck...

To give a brief process flow:

Page 1-
Users login with a user_id and password. Click SUBMIT. From here, page 2 is loaded.

Page 2-
Has query that checks database to see if user_id is a supervisor. If the user_id is not a supervisor, page 2 executes several queries and displays benefit information about the user_id. If the user_id is a supervisor, I don't want page 2 to display at all. Instead, redirect to page 3. To verify that my parameters are making it to page 2, I echo the $user_id, $password, and $sup_flag, all echo with expected values.

I need pass the user_id over to page 3. I would prefer it not display in the address. This is why I was trying to use POST method.

Still working on it. Thanks for the suggestion.
 
I am going to go with session variables. As this is my third project with PHP, I have not yet had to use session variables. From the brief reading I've done, they sound exactly like what I need.

Thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top