Forum Moderators: coopster
Thank you for any help you can provide.
In your case, I think the problem lies in your redirect to the homepage, as you stated.
When you redirect after form submission, you will need to add the form information to the URL in your redirect. Not with hidden form fields, but by building the 'querystring'.
The redirect in PHP:
header("Location:/thank_you.php?name=$name&whatever=$whatever");
The part starting with "?" is the querystring.
Hope that helps you get on track.
<?php
session_start();
session_unregister('email');
session_register('email');
$email = $HTTP_POST_VARS[email];
session_unregister('name');
session_register('name');
$name = $HTTP_POST_VARS[name];
?>
I知 not sure if this is correct, but I was trying to follow a tutorial on sessions and this is what they showed. I can carry not just name and email, but all of the inputs fields with this from page to page in my form. Where I have problems is in the form redirect when you click on send:
<input type="hidden" name="redirect" value="http://mysite.com/thank_you.php">
I loose the data I知 trying to carry over, email and name. I致e tried various ways to send the session in the redirect but so far no luck. I致e been trying to read the manual at php.net but not understanding exactly what I知 reading. I知 sure in time I値l get it, but I知 under a time restraint to get this page done.
Any assistance is very welcome!
Thank you, Jack
How do you have the form set up?
Are you using seperate files? If you're using just one file, it may be slightly easier-
A possible approach (apologies for messy code)
<?
/* form.php */
/* multiple forms in one php file */
if ($_REQUEST['page'] == "page1" ヲヲ!isSet($_REQUEST['page']))
{
?>
<form method="post" action="<? echo($_SERVER['PHP_SELF'] . "page=page2");?>">
Name: <input type="text" name="name" /><br />
E-mail: <input type="text" name="email" /><br />
<input type="submit" value="Submit" /></form>
<?
}
else if ($_REQUEST['page'] == "page2")
{
$email = $_POST['email'];
$name = $_POST['name'];
?><! -- form for page 2 , set it to post to page 3--><?
}
else if ($_REQUEST['page'] == "page3")
{
?> Thank you for filling out the form <? /* php to add $name, $email, and any other fields to DB */
}
?>