I have a landing page with an interest form.
People who are interested leave their name and email address. The contact1.php forms emails me with their information. That works. (Yay me!)
Now - I want to dress things up a bit and don't know how. I have read till my eyes are square and headaches are constant. So now I ask for help.
The process is as follows:
Landing Page > contact1.php > thanks1.html > contact2.php > thanks2.html
1) I would like this to appear on the thanks1.html
"Thanks [firstname]. An email sent to [email] is coming your way. (I won't post what I tried - it didn't work.)
2) Then on the thanks1.html page, there are extra fields that the person can fill out if they want. I would like the firstname and email to be passed from the landing page and the extra fields in the thanks1.html page to be appended and all of the info to be emailed.
3) What coding should be in contact2.php? This would be the file that thanks1.html sends the form info to. It may be similar to contact1.php but I don't know for sure.
4) Then on thanks2.html the same message
"Thanks [firstname]. An email sent to [email] is coming your way." I would think it would be the same as thanks1.html.
Thanks for your help. I really appreciate it.
Randy
The code from each piece as I have it. If there is a better way to make this work, I am open to it.
Form in landing page:
[code=html] <form action="contact1.php" method="post">
<table style="text-align: left; width: 219px; height: 88px;" border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="vertical-align: top;">
<table style="text-align: left; width: 214px; background-color: rgb(255, 255, 153); height: 83px;" border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top;">Name</td>
<td style="vertical-align: top;"><input name="firstname" type="text"></td>
</tr>
<tr>
<td style="vertical-align: top;">E-mail</td>
<td style="vertical-align: top;"><input name="email" type="text"></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<p><input value="Submit" type="submit"></p>
</form>
Contact1.php
<?php
/* Set e-mail recipient */
$myemail = "email@domain.com";
/* Check all form inputs using check_input function */
$firstname = check_input($_POST['firstname'], "Please enter your first name");
$email = check_input($_POST['email'], "Please enter your email address");
/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
show_error("E-mail address not valid");
}
/* Let's prepare the message for the e-mail */
$message = "Hello!
A client entered the following information:
First Name: $firstname
E-mail: $email
";
/* Send the message using mail() function */
mail($myemail, 'Form Name', $message);
/* Redirect visitor to the thank you page */
header('Location: thanks1.html');
exit();
/* Functions we used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
</head>
<body>
<b>Please correct the following error - Just press the Back button on your browser to fill out the missing fields. Thank you.</b><br>
<?php echo $myError; ?><?php exit();
}
?>
thanks1.html form
<form action="contact2.php" method="post">
<table style="text-align: left; width: 286px; height: 88px;" border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="vertical-align: top;">
<table style="text-align: left; width: 282px; background-color: rgb(255, 255, 153); height: 83px;" border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top;">Phone</td>
<td style="vertical-align: top;"><input name="phone" type="text"></td>
</tr>
<tr>
<td style="vertical-align: top;">Best Time To
Call</td>
<td style="vertical-align: top;"><input name="call" type="text"></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<p><input value="Call Me To Talk" type="submit"></p>
</form>