View Full Version : php redirect with dynamic url

05-02-2007, 11:20 PM
i have a form on my site and once filled out, the user is redirected to a page outside my site. i now would like to have them redirected to another page in my site and then redirected again outside the site to that same page. the info entered in the form creates the url that leads outside the site...is it possible to keep this with the addition of the internal page?

does this make sense?

05-02-2007, 11:47 PM
You could call the variables from the original form in the page that the user gets redirected to (within your site). By using $_POST, $_GET, or $_REQUEST you could get these values and then forward them to the external page.

Hope this helps.

05-03-2007, 12:49 AM
On the receiving page, for example,
header('Location: http://my.com/'.$_POST['page'].'.php');

05-03-2007, 03:33 AM
thanks for your responses. sorry if i was unclear, i am fairly new to all of this. so if i am understanding you correctly....

this is the code i have that passes the variables to the url:

$offerCode = "1234";
$checkCode = "cc";
$shortKey = "cccccc";
$longKey = "123456";
$pin = $_REQUEST['email'];

$eCoupon = new Coupon();
$coupon_url = $eCoupon->generateURL($pin, $offerCode, $shortKey, $longKey, $checkCode);

header("Location: ".$coupon_url);

so when the user hits submit...the form uses the post method to call the file with the above code.

so i would use the above code by dj233 to obtain the parameters? would it also be possible to change the code i provided to redirect to the new internal page and then when it redirects pass them along to the external page? and when you say 'page' above...are you referring to the new internal? again, sorry i am new.

thanks again for all of your help...

05-08-2007, 05:58 PM
this seems to be working except that the email variable is not getting passed along. so for example, i have:

-form.php (what the html form gets posted to):

header("Location: /internal.php");


$var = "123";
$var2 = "456";
$email = $_REQUEST['email']; // in html form

$eurl = new Url();
$new_url = $eurl->generateURL($email, $var, $var2);
header("Location: ".$new_url);

generateURL is in a separate file with the code to build that.

it redirects fine, but it errors at the external page showing that it is missing a parameter ( so far as i can tell it is only missing the email).

can anyone help? thanks.

05-09-2007, 09:48 PM
You need to put $_REQUEST['email'] into a hidden input on form.php, use javascript to automatically submit form.php to internal.php carrying $_REQUEST['email'] with it.