I have a few forms on my website which I need site visitors to submit in sequence.
‘form1’ sends the user data to the (php mailto) form mailer.
The header(location) of the form mailer then directs the site visitor to a page with ‘form2’.
I need a php solution to pre-populate form2 with the previously submitted data from form1.
I would like a slicker alternative to passing the data through the URL.
Form 1:
<form id="form1" action="formMailer.php" method="post">
Name: <input type="text" id="userName" name="userName" value="">
Email: <input type="email" id="userEmail" name="userEmail" value="">
<input type="submit" id="submitButton" name="submitButton" value="Submit">
PHP Form Mailer:
<?php
$name = $_POST['userName'];
$email = $_POST['userEmail'];
$message =
"rnYour Name: " .$name .
"rnYour Email: " .$email;
$subject ="Subject of email";
$mailto = "[email protected]";
$separator = md5(uniqid(time()));
$eol = "rn";
$headers = "From: ".$name." <".$email.">" . $eol;
$headers .= "MIME-Version: 1.0" . $eol;
$headers .= "Content-Type: multipart/mixed;". $eol. " boundary="" . $separator . """ . $eol;
$headers .= "This is a MIME encoded message." . $eol . $eol;
$body = "--" . $separator . $eol;
$body .= "Content-Type: text/plain; charset="iso-8859-1"" . $eol;
$body .= "Content-Transfer-Encoding: 8bit" . $eol . $eol;
$body .= $message . $eol;
mail($mailto, $subject, $body, $headers);
header('location: /formFolder/form2.php');
?>
Form 2:
<form id="form2" action="nextAction" method="post">
Name: <input type="text" id="userName" name="userName" value="">
Email: <input type="email" id="userEmail" name="userEmail" value="">
Other Data: <input type="text" id="other_userData" name="other_userData" value="">
<input type="submit" id="submitButton" name="submitButton" value="Submit">
I tried some php ‘get’ and ‘echo’ script, but it seems the data gets lost somewhere between the mailto and the second form.