BXmanagement
10-17-2007, 02:53 PM
Hi,
I have created a contact form for my clients to contact our technical support department. On the contact form, there is a text box where the user is required to put their email address ($Email). Once the user clicks "submit" the contact form details are sent to an email address. How can I have the "reply to:" in the submitted email, be the email address ($Email) the user supplied?
Here is my contact form page - helpinghandhost.com/support/templates/custom/supportticketsubmit-techsupport.html
Here is my php code -
<?php
// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
$EmailTo = "admin@helpinghandhost.com";
$Subject = "Technical Support Request";
$Name = Trim(stripslashes($_POST['name']));
$Email = Trim(stripslashes($_POST['email']));
$Department = Trim(stripslashes($_POST['department']));
$Subject = Trim(stripslashes($_POST['subject']));
$Urgency = Trim(stripslashes($_POST['urgency']));
$cPanelUser = Trim(stripslashes($_POST['cpaneluser']));
$cPanelPass = Trim(stripslashes($_POST['cpanelpass']));
$Message = Trim(stripslashes($_POST['message']));
// validation
$validationOK=true;
if (Trim($Name)=="") $validationOK=false;
if (Trim($Email)=="") $validationOK=false;
if (Trim($Subject)=="") $validationOK=false;
if (Trim($Urgency)=="") $validationOK=false;
if (Trim($cPanelUser)=="") $validationOK=false;
if (Trim($cPanelPass)=="") $validationOK=false;
if (Trim($Message)=="") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Subject = "Tech Support Request";
$Body = "";
$Body .= "EmailFrom: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Department: ";
$Body .= $Department;
$Body .= "\n";
$Body .= "Subject: ";
$Body .= $Subject;
$Body .= "\n";
$Body .= "Urgency: ";
$Body .= $Urgency;
$Body .= "\n";
$Body .= "cPanel Username: ";
$Body .= $cPanelUser;
$Body .= "\n";
$Body .= "cPanel Password (1st character): ";
$Body .= $cPanelPass;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body);
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
Thank you!
I have created a contact form for my clients to contact our technical support department. On the contact form, there is a text box where the user is required to put their email address ($Email). Once the user clicks "submit" the contact form details are sent to an email address. How can I have the "reply to:" in the submitted email, be the email address ($Email) the user supplied?
Here is my contact form page - helpinghandhost.com/support/templates/custom/supportticketsubmit-techsupport.html
Here is my php code -
<?php
// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
$EmailTo = "admin@helpinghandhost.com";
$Subject = "Technical Support Request";
$Name = Trim(stripslashes($_POST['name']));
$Email = Trim(stripslashes($_POST['email']));
$Department = Trim(stripslashes($_POST['department']));
$Subject = Trim(stripslashes($_POST['subject']));
$Urgency = Trim(stripslashes($_POST['urgency']));
$cPanelUser = Trim(stripslashes($_POST['cpaneluser']));
$cPanelPass = Trim(stripslashes($_POST['cpanelpass']));
$Message = Trim(stripslashes($_POST['message']));
// validation
$validationOK=true;
if (Trim($Name)=="") $validationOK=false;
if (Trim($Email)=="") $validationOK=false;
if (Trim($Subject)=="") $validationOK=false;
if (Trim($Urgency)=="") $validationOK=false;
if (Trim($cPanelUser)=="") $validationOK=false;
if (Trim($cPanelPass)=="") $validationOK=false;
if (Trim($Message)=="") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Subject = "Tech Support Request";
$Body = "";
$Body .= "EmailFrom: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Department: ";
$Body .= $Department;
$Body .= "\n";
$Body .= "Subject: ";
$Body .= $Subject;
$Body .= "\n";
$Body .= "Urgency: ";
$Body .= $Urgency;
$Body .= "\n";
$Body .= "cPanel Username: ";
$Body .= $cPanelUser;
$Body .= "\n";
$Body .= "cPanel Password (1st character): ";
$Body .= $cPanelPass;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body);
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
Thank you!
