Greetings everyone!
I don't have much experience with PHP and I hope someone can help me with a form that I'm having problems with. The user accesses the form using a short cut. To prevent them from having to complete fields that don't change some of the fields are completed using the shortcut URL. E.g.
[FONT=Courier New]http://service.my-website.com/index.php?siteName=My_Site&street=123_The_Street&city=My_City&state=SD&zip=12345&tag=Tag1&equipment=Control_Station[/FONT]
To remove the underscores from the form fields I use this code for each field:
<?php
if (isset($_GET['fieldName'])) {
$siteName = $_GET['siteName'];
$siteNameNS = preg_replace("/[_]/", " ", $siteName);
echo "value=" . $siteNameNS;
} else {
echo "";
}
?>
This removes the underscores but seems to prevent the email from being delivered.
Here's my email form:
<?php
//Procees portal.php data into an email
$to = "technicalcallcenter@emailserver.com";
$subject = "Service Request from " . $_POST['siteName'];
$body = "A service request has been recieved from ". $_POST['contactName'] . " at " . $_POST['siteName'] . "\n \n" .
"Site Name: " . $_POST['siteName'] . "\n \n" .
"Street: " . $_POST['street'] . "\n \n" .
"City: " . $_POST['city'] . "\n \n" .
"State: " . $_POST['state'] . "\n \n" .
"Zip Code: " . $_POST['zip'] . "\n \n" .
"Contact Name: " . $_POST['contactName'] . "\n \n" .
"Phone Number: ". $_POST['phone'] . "\n \n" .
"Email: " . $_POST['email'] . "\n \n" .
"Customer #, Equipment Serial # OR Tag #: " . $_POST['tag'] . "\n \n" .
"Error Code or Message: " . $_POST['errorCode'] . "\n \n" .
"Equipment Type: " . $_POST['equipment'] . "\n \n" .
"Description of the problem: " . "\n" . $_POST['description']
;
$headers = "From: Technical Support <service@my-website.com>" . "\n";
mail($to,$subject,$body,$headers);
//Send confirmation email
$replyTo = $_POST['email'];
$replySubject = "Konica Minolta Service Request";
$replyBody = "Dear ". $_POST['contactName'] . ";" . "\n \n" .
"Thank you for your service request. A Specialist will be contacting you as soon as they become available." . "\n \n" .
"Our hours for email response are between 8:00am to 8:00pm Eastern Time Zone, Monday through Friday. If you have an emergency that requires immediate assistance outside of normal hours please call our call center at 1-800-000-0000 which is available 24 hours a day 7 days a week including holidays." ;
mail($replyTo,$replySubject,$replyBody,$headers);
//Forward to confirmation web page
header('Location: /confirm.php');
?>
In all instances the confirmation email is sent and received and the user is sent to the confirm.php webpage. But, when I implement the code which removes any underscores from the form fields the email generated by the form is not received. However, if I disable that code or if I fat finger the information in to the form then the email is received.
Any help resolving this would be awesome and much appreciated!
Thanks!