Forum Moderators: coopster
Can someone show me the way to pass data from form_1 then to form_2 then to form_3 in php.
I can get the ['var'] in form 2 but when i call the action="" to form_3 the form is blank, no ['var'].
THE THIRD FORM MUST BE THE ONE SUBMITTING TO THE SPECIFIC EMAIL. When I get the email all the ['var'] are blank.
I am doing this without a database so that my forms can be self procees.
Can anyone help this up and comming php GURU fro SA.
Thanks in advance.
I can get the ['var'] in form 2 but when i call the action="" to form_3 the form is blank, no ['var'].
When form 1 is submitted you can store the necessary 'persistent' vars in form 2 (when you write out form 2) in hidden fields, like:
<input type="hidden" name="form1_someinfo" value="ThisValueCameFromForm1">
When form 2 is submitted then this hidden field is submitted as well - you then have to read this hidden field when form 2 is processed, otherwise the information will be lost.
Is that the sort of thing you are doing?
Or, you could use SESSIONs [uk2.php.net], which would avoid having to pass information from form to form.
Welcome to WebmasterWorld :)
What must I put in value="ThisValueCameFromForm1"?
I can echo the 'var' in form2, But I cant pass them to the next form. Take a look on the code I am ussing:
Form1
<input name="name" type="text" id="name" size="30" />
Form2
//here I call the hidden 'var' from form1 by this code:
<input name="name" type="hidden" id="name" size="30" /><?php $name = $_POST['name']; echo $name; ?>
Form3
// here I receive blank Name constant without a 'var' that appeared in form2, with this code
<input name="name" type="hidden" id="name" size="30" />
<?php $name = $_POST['name']; echo $name; ?>
Hope i makes sense.
//here I call the hidden 'var' from form1 by this code:
<input name="name" type="hidden" id="name" size="30" /><?php $name = $_POST['name']; echo $name; ?>
I think should read:
<input name="name" type="hidden" id="name" value="<?php echo $_POST['name']; ?>" />
The value of the INPUT element comes from the value of the VALUE attribute, not from what follows it. What follows the INPUT element will get output to the page, which is not what you require in this instance.
<input name="name" type="hidden" id="name" value="<?php echo htmlentities($_POST['name']); ?>" />
But I still cant get it to work on form3.
Did the values get to form2? If you view the source of your 2nd page do you see the values from form1? It's the same principle to then get them to form3.
An example...
With 4 pages. "page1.php", "page2.php" and "page3.php" each have a form continuing from the last so the values are passed along. "the_end.php" just displays all the values.
page1.php (Form 1)
<form action="page2.php" method="post">
Name: <input type="text" name="f1name" value="">
<input type="submit" name="f1submit" value="Next">
</form>
page2.php (Form 2)
<form action="page3.php" method="post">
<input type="hidden" name="f2name" value="<?php echo htmlentities($_POST['f1name']); ?>">
Address: <input type="text" name="f2address" value="">
<input type="submit" name="f2submit" value="Next">
</form>
page3.php (Form 3)
<form action="the_end.php" method="post">
<input type="hidden" name="f3name" value="<?php echo htmlentities($_POST['f2name']); ?>">
<input type="hidden" name="f3address" value="<?php echo htmlentities($_POST['f2address']); ?>">
Phone: <input type="text" name="f3phone" value="">
<input type="submit" name="f3submit" value="Send">
</form>
the_end.php
<p>You entered:<br>
Name: <?php echo htmlentities($_POST['f3name']); ?><br>
Address: <?php echo htmlentities($_POST['f3address']); ?><br>
Phone: <?php echo htmlentities($_POST['f3phone']); ?>
</p>
Form 3 basically ends up with ALL the values from Form 1 and Form 2 but in hidden fields. Does that work for you?
Here's what i have done: if($city == "Witbank" && $passengers == 3) {$total = $witbank1 * $witbank2;}else {$total = $witbank1 * $passengers;}
//when I tell my script that i have chosen another city it does all the calculations but the total is wrong. How do I get this right
Thanks in advance.