Forum Moderators: open
I have a page on my site from which people go through to a contact form. This first page sends a couple of hidden fields through to the contact page, which is written in php.
Once they've submitted their details (which writes them to a SQL db), I'd like to know if its possible to have them automatically re-directed to another page - the URL of which is generated by the FIRST page.
In other words, they come from page1.htm and go to contact.php. Upon submit of contact.php, I'd like them to go to a URL which is generated by page1.htm : hence, if they approach by page2.htm instead of page1.htm, page2.htm sends them to a different URL than page1.htm does.
Are you still with me? Can I do this?
Thanks a lot.
<a href="/contact.php?url=/somewhere.php">Contact us</a>
Then, in the <form>(contact.php), write that variable into a hidden form field. Like this:
<input type="hidden" name="url" value="<?php print($_GET["url"]);?>" />
Finally, in the script that writes to the db, add a redirect header at the end of the script. Like this:
header("Location: ".$_POST["url"]);
That should do it for you.