Page 1 of 1

Redirect Question, Thanks for any help!

Posted: Tue Dec 16, 2008 4:43 pm
by jwd
Hi there... I'd appreciate any help... and I'm by no means asking anyone to do my work for me. If any knows of any tutorials or anything that may help me, I'd appreciate!

Basically I have a form (not an email form) that when you hit submit it calls another php file for the processing. In that file it has the header(Location:... for the redirect.

HOWEVER, I don't want it to redirect based on that. I want in the form to be able to specify a hidden field (or however best to do it) called "redirect" and the value be a URL.

So that way when someone clicks submit it will call the other php file to process (and ignore the headerLocation-- or I can just remove that) and then redirect to the page specified in the form.

THANKS so much in advance for any advice, help or pointing me somewhere to learn.

Re: Redirect Question, Thanks for any help!

Posted: Tue Dec 16, 2008 4:58 pm
by Reviresco
Assuming you have your URL in a variable called $url_for_redirect:

In the form:

Code: Select all

<input type="hidden" name="redirect" value="<?php echo $url_for_redirect; ?>"  />
In the form processing script:

Code: Select all

<?php
$url_to_go_to = $_POST['redirect'];
?>
 
At end of script:

Code: Select all

 
<?php
header('Location: ' . $url_to_go_to);
?>
 

Re: Redirect Question, Thanks for any help!

Posted: Tue Dec 16, 2008 5:26 pm
by jwd
I made a silly mistake, which is why I edited this to take it away.

That ended up working like a charm once I found what I did wrong.

Anyway- THANKS so much!