Jump to content

How would IModify an "form to email" php file to also send a confirmation email?


ghurty

Recommended Posts

I have a php file that is called from a  form in a flash file to send an email to one address.

 

I want it that instead of just emailing the address that the form is pointed to, it should also also email a confirmation email to the address that was put into the "from" spot in the form.

 

How would I go about doing that.

 

Thanks

 

<?php
Error_Reporting(E_ALL & ~E_NOTICE);

while ($request = current($_REQUEST)) {
    if (key($_REQUEST)!='recipient') {
      $pre_array=split ("&777&",  $request);
      
      $post_vars[key($_REQUEST)][0]=preg_replace ("/<[^>]*>/", "", $pre_array[0]);
      $post_vars[key($_REQUEST)][1]=preg_replace ("/<[^>]*>/", "", $pre_array[1]);
   }
   next($_REQUEST);
}



reset($post_vars);


$subject="From ".$post_vars['your_name'][0] ;
$headers= "From: ".$post_vars['your_email'][0] ."\n";
$headers.='Content-type: text/html; charset=iso-8859-1';
$message='';
  while ($mess = current($post_vars)) {
     if ((key($post_vars)!="i") && (key($post_vars)!="your_email") && (key($post_vars)!="your_name")) {

       $message.="<strong>".$mess[1]."</strong>   ".$mess[0]."<br>";
   }
   next($post_vars);
}

mail($_REQUEST['recipient'], $subject,  "
<html>
<head>
<title>Contact letter</title>
</head>
<body>
<br>
  ".$message."
</body>
</html>" , $headers);
?>
<script>
   window.close()
</script>

Have you ever sent an email to more than one person using Yahoo or Gmail? All you do it add a comma and an email address right? Well you can do the same with the mail function. Add post_vars['your_name'][0] after $_REQUEST['recipient'] in your mail function. I think you'll need to put in a comma too.

Blindly sending an email to the email address that is provided to your form processing code will quickly cause your mail server to get banned by the major ISP's because every bot script that finds your form processing code will cause a nuisance email to be sent to the email address the bot script provides.

 

The visitor is already on your web site, just output a thank you message to the browser.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.