Jump to content

Passing variable values between pages


Evrim

Recommended Posts

Hello

 

I have a form on html page which posts its results to a PHP page.

PHP page gets the values of form elements and redirects to the right page.

 

So at the end of PHP page I have:

 

if ($v==1)
  $resulturl ='../thanks.htm';
else
  $resulturl ='../incomplete.htm';

$headers = "From: $from ". "\r\n"; 
  header("Location: $resulturl");

 

My question is, how can I pass the variable $v to my page incomplete.htm?

 

Thank you for your help ???

 

EDITED BY akitchin: added code tags. use them in all future posts please.

Link to comment
https://forums.phpfreaks.com/topic/162779-passing-variable-values-between-pages/
Share on other sites

First you should use double quotes for your link variables.

Second, you have to use the GET method and tack on the variable to the end of the URL.  Or you can use a hidden field and pass it along.  Or you can use sessions.  The first option is the easiest.

 

if ($v==1)
  $resulturl ="../thanks.htm";
else
  $resulturl ="../incomplete.htm?v=$v";

$headers = "From: $from ". "\r\n";
  header("Location: $resulturl");

 

Now when you get the incomplete.php you have to use $_GET['v']; to retrieve the value.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.