As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/
Options

Help with a PHP Mailer Script... Needs to Reply to Sender.

powersspowerss Registered User regular
edited May 2007 in Help / Advice Forum
So, I have this little contact script that I'm using on a friend's companies website to redirect to a "download" page to receive the companies brochure.

Basically, they've been having problems with people spoofing their addresses (dummy information).

Here's the script:
<?php
// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); 
$EmailTo = "vijay@a-k-a.net";
$Subject = "AKA Website - Download PDF Registrant";
$Name = Trim(stripslashes($_POST['Name'])); 
$Title = Trim(stripslashes($_POST['Title'])); 
$Company = Trim(stripslashes($_POST['Company'])); 
$PhoneNumber = Trim(stripslashes($_POST['PhoneNumber'])); 

// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=dl_error.shtml\">";
  exit;
}

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Title: ";
$Body .= $Title;
$Body .= "\n";
$Body .= "Company: ";
$Body .= $Company;
$Body .= "\n";
$Body .= "PhoneNumber: ";
$Body .= $PhoneNumber;
$Body .= "\n";

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=pdf/brochure.pdf\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=dl_error.shtml\">";
}
?>

What I'd like the script to do is still email my friend at the company with the info they inputted, but also send the person who filled out the form an quick email with a download link in it.

Anyone care to edit the code/give suggestions?

Thanks a million.

powerss on

Posts

  • Options
    12gauge12gauge Registered User regular
    edited May 2007
    mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
    
    Just write another call to mail and replace the $EmailTo with the customers email and put the download-link into the body.

    Then put that call into your if/else:
    if ($success){
      //new code here, you have tp adjust the variables of course
      $downloadSent = mail($CustomerEmail, $Subject, $DLinkBody, "From: <$EmailFrom>");
      // Here you can check if the email was sent out and maybe redirect to another webpage if it did not work
      print "<meta http-equiv=\"refresh\" content=\"0;URL=pdf/brochure.pdf\">";
    }
    

    12gauge on
    davidoc0.jpg
  • Options
    powersspowerss Registered User regular
    edited May 2007
    Thank you so much dude. Really. I bow.

    powerss on
Sign In or Register to comment.