Geezer D
01-20-2010, 03:33 PM
Hi, all.
My client has a form on their site which they want me to add a function to which sends the user a confirmation email with a title like "Please send us more information for a more precise quote", and a message like "We received your form submission, but to give you a more precise..etc, etc"
I'm nearly clueless on PHP, can anyone out there give me the code I'd need to do this?
This is the form as it is now:
<?
// EMAILRIFIC Check
function checkValidEmail($addy)
{
list($userName, $mailDomain) = split("@", $addy);
if(!stristr($mailDomain,'.'))
{
return false;
}
else if(checkdnsrr($mailDomain, "MX"))
{
return true;
}
else
{
return false;
}
}
if($_REQUEST['go'])
{
if(!$_REQUEST['name']){
$error .= "Please Enter Your Name<br>";
}
if(!$_REQUEST['company']){
$error .= "Please Enter a Company Name<br>";
}
if(!$_REQUEST['employees']){
$error .= "Please Enter Number of Employees<br>";
}
if(!$_REQUEST['email']){
$error .= "Please Enter a Valid Email Address<br>";
}
else if(!checkValidEmail($_REQUEST['email'])){
$error .= "The Email Address You Entered Does Not Appear To Be Valid<br>";
}
if(!$_REQUEST['message']){
$error .= "Please Enter a Message To Be Sent<br>";
}
include("securimage/securimage.php");
$img = new Securimage();
$valid = $img->check($_POST['code']);
if($valid == false)
{
$error .= "The code you entered was invalid to continue, please enter the code again<br />";
}
if(!$error)
{
$message = "A contact request has been filled out at your website with the following information. \n \n".
"Name: ".$_REQUEST["name"]." \n".
"Company Name: ".$_REQUEST["company"]." \n".
"Number of Employees: ".$_REQUEST["employees"]." \n".
"Phone: ".$_REQUEST["phone"]." \n".
"Email: ".$_REQUEST["email"]." \n\n".
"Message: \n".
$_REQUEST["message"];
$to = 'info@thesite.com';
$subject = 'The Site Website Contact Form';
$headers = 'From: '.$_REQUEST["name"].' <'.$_REQUEST["email"].'>' . "\r\n" .
'Reply-To: '.$_REQUEST["name"].' <'.$_REQUEST["email"].'>' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
echo "<h2>Thank You.</h1>
<p>Your Message has been sent, and we will be in contact shortly!</p>";
}
}
if(!$_REQUEST['go'] || $error)
{
if($error){ echo '<b>'.$error.'</b>';}
?>
<form action="information2.php" method="post">
<table width='100%' cellpadding="4">
<tbody>
<tr>
<td class="TableBody1">
*Name</td>
<td>
<input name='name' type='text' id='name' value="<?=$_REQUEST[name];?>" size='30' />
</td>
</tr>
<tr>
<td class="TableBody1">
*Company</td>
<td>
<input name='company' type='text' id='company' value="<?=$_REQUEST[company];?>" size='30' />
</td> </tr>
<tr>
<td class="TableBody1">
*Number of Employees</td>
<td>
<input name='employees' type='text' id='employees' value="<?=$_REQUEST[employees];?>" size='6' />
</td> </tr>
<tr>
<td class="TableBody1">
Phone</td>
<td>
<input name='phone' type='text' id='phone' value="<?=$_REQUEST[phone];?>" size='30' />
</td> </tr>
<tr>
<td class="TableBody1">
*Email Address</td>
<td> <input name='email' type='text' id='email' value="<?=$_REQUEST[email];?>" size='30' />
</td> </tr>
<tr>
<td valign="top" class="TableBody1">
*Message</td>
<td>
<textarea id='message' rows='6' cols='50' name='message'><?=$_REQUEST[message];?></textarea>
</td> </tr>
<tr>
<td valign="top" class="TableBody1"> </td>
<td>
<p>To send your message, please fill out the box below with the code in the image</p>
<img src="securimage/securimage_show.php?sid=<?php echo md5(uniqid(time())); ?>"><br />
<input type="text" name="code" id="code" value="" />
</td> </tr>
<tr><td></td>
<td> <input type='submit' value='Submit' name='go' />
</td> </tr> </tbody></table>
</form>
<? } ?>
Thanks in advance.
My client has a form on their site which they want me to add a function to which sends the user a confirmation email with a title like "Please send us more information for a more precise quote", and a message like "We received your form submission, but to give you a more precise..etc, etc"
I'm nearly clueless on PHP, can anyone out there give me the code I'd need to do this?
This is the form as it is now:
<?
// EMAILRIFIC Check
function checkValidEmail($addy)
{
list($userName, $mailDomain) = split("@", $addy);
if(!stristr($mailDomain,'.'))
{
return false;
}
else if(checkdnsrr($mailDomain, "MX"))
{
return true;
}
else
{
return false;
}
}
if($_REQUEST['go'])
{
if(!$_REQUEST['name']){
$error .= "Please Enter Your Name<br>";
}
if(!$_REQUEST['company']){
$error .= "Please Enter a Company Name<br>";
}
if(!$_REQUEST['employees']){
$error .= "Please Enter Number of Employees<br>";
}
if(!$_REQUEST['email']){
$error .= "Please Enter a Valid Email Address<br>";
}
else if(!checkValidEmail($_REQUEST['email'])){
$error .= "The Email Address You Entered Does Not Appear To Be Valid<br>";
}
if(!$_REQUEST['message']){
$error .= "Please Enter a Message To Be Sent<br>";
}
include("securimage/securimage.php");
$img = new Securimage();
$valid = $img->check($_POST['code']);
if($valid == false)
{
$error .= "The code you entered was invalid to continue, please enter the code again<br />";
}
if(!$error)
{
$message = "A contact request has been filled out at your website with the following information. \n \n".
"Name: ".$_REQUEST["name"]." \n".
"Company Name: ".$_REQUEST["company"]." \n".
"Number of Employees: ".$_REQUEST["employees"]." \n".
"Phone: ".$_REQUEST["phone"]." \n".
"Email: ".$_REQUEST["email"]." \n\n".
"Message: \n".
$_REQUEST["message"];
$to = 'info@thesite.com';
$subject = 'The Site Website Contact Form';
$headers = 'From: '.$_REQUEST["name"].' <'.$_REQUEST["email"].'>' . "\r\n" .
'Reply-To: '.$_REQUEST["name"].' <'.$_REQUEST["email"].'>' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
echo "<h2>Thank You.</h1>
<p>Your Message has been sent, and we will be in contact shortly!</p>";
}
}
if(!$_REQUEST['go'] || $error)
{
if($error){ echo '<b>'.$error.'</b>';}
?>
<form action="information2.php" method="post">
<table width='100%' cellpadding="4">
<tbody>
<tr>
<td class="TableBody1">
*Name</td>
<td>
<input name='name' type='text' id='name' value="<?=$_REQUEST[name];?>" size='30' />
</td>
</tr>
<tr>
<td class="TableBody1">
*Company</td>
<td>
<input name='company' type='text' id='company' value="<?=$_REQUEST[company];?>" size='30' />
</td> </tr>
<tr>
<td class="TableBody1">
*Number of Employees</td>
<td>
<input name='employees' type='text' id='employees' value="<?=$_REQUEST[employees];?>" size='6' />
</td> </tr>
<tr>
<td class="TableBody1">
Phone</td>
<td>
<input name='phone' type='text' id='phone' value="<?=$_REQUEST[phone];?>" size='30' />
</td> </tr>
<tr>
<td class="TableBody1">
*Email Address</td>
<td> <input name='email' type='text' id='email' value="<?=$_REQUEST[email];?>" size='30' />
</td> </tr>
<tr>
<td valign="top" class="TableBody1">
*Message</td>
<td>
<textarea id='message' rows='6' cols='50' name='message'><?=$_REQUEST[message];?></textarea>
</td> </tr>
<tr>
<td valign="top" class="TableBody1"> </td>
<td>
<p>To send your message, please fill out the box below with the code in the image</p>
<img src="securimage/securimage_show.php?sid=<?php echo md5(uniqid(time())); ?>"><br />
<input type="text" name="code" id="code" value="" />
</td> </tr>
<tr><td></td>
<td> <input type='submit' value='Submit' name='go' />
</td> </tr> </tbody></table>
</form>
<? } ?>
Thanks in advance.