I’m using a jQuery form to submit requests for information, but am getting some really inconsistent results when the form submission is sent to the PHP page for processing. I’ll fill out the form, hit submit, and sometimes it’ll return correctly, other times error out - even without changing anything or even refreshing the page. The page I’m talking about is here: http://www.amberleafrealty.com/properties/79801033
The backend processing page is below. Can anyone see anything that I should change? I’m just looking for reliable submissions here.
<?php include_once "../cfg/config.php"; // retrieve entered values $name = trim($_GET["name"]); $email = trim($_GET["email"]); $phone = trim($_GET["phone"]); $message = $_GET["message"]; $xcrn = trim($_GET["xcrn"]); $xtag = trim($_GET["xtag"]); $cleanphone = preg_replace("/[^0-9]/","",$phone); $phonepres = "(".substr($cleanphone, 0, 3).") ".substr($cleanphone, 3, 3)."-".substr($cleanphone,6); $cleanmessage = addslashes($message); // create sql statement $sql = "INSERT INTO re_amberleaf.tbl_messages SET me_name = '$name', me_phone = '$cleanphone', me_email = '$email', me_message = '$cleanmessage', me_ref = '$xcrn'"; dbConnect($db_name); $result = mysql_query($sql); $newid = mysql_insert_id(); if (!$result) { // if a database error occurs stop error("A error occurred while logging your request. \\nIf this error persists, please contact $admin_email."); } else { // otherwise - send the request email // assemble email message include("../cfg/class.phpmailer.php"); include("../cfg/class.smtp.php"); $agentbody = "A New Message for you from $nameName: | $name |
Email: | |
Phone: | $phonepres |
Reference: | $xcrn |
Message:
$message
Thank you for visiting our website at www.amberleafrealty.com and
requesting more information about one of our properties.
As a summary, the information you submitted is below.
Name: | $name |
Email: | |
Phone: | $phonepres |
Reference: | $xcrn |
Message:
$message
You now have access to all available documents for this property, and can reach them by clicking the link below
Property Files »We will follow up with you by phone within the next 24 hours. If you should have any questions before then, please don't hesitate to contact us!
Brian Varvel
Amberleaf Realty Group
Keller Williams Premier Realty
22762 Westheimer Parkway, Suite 430
Katy, Texas 77450
(281) 712-2465 Direct
(281) 220-8983 Fax
brian@amberleafrealty.com"; $guestalt = "Thank you for visiting our website at www.amberleafrealty.com and requesting more information about one of our properties. As a summary, the information you submitted is below./n/nName: $name/nEmail: $email/nPhone: $phone/nReference: $xcrn/nMessage:/n$message/n/nYou now have access to all available documents for this property, and can reach them by copying and pasting this link into your browser: http://www.amberleafrealty.com/properties/$xtag?vid=$newid/n/nWe will follow up with you by phone within the next 24 hours.
If you should have any questions before then, please don't hesitate to contact us!/n/n Brian Varvel/nAmberleaf Realty Group/nKeller Williams Premier Realty/n22762 Westheimer Parkway, Suite 430/nKaty, Texas 77450/n(281) 712-2465 Direct/n (281) 220-8983 Fax/nbrian@amberleafrealty.com"; $mail = new PHPMailer(); // send email to me $mail->IsSMTP(); // set to use SMTP $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "ssl"; // sets the prefix to the servier $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server $mail->Port = 465; // set the SMTP port $mail->Username = "sending@emailaddress.com"; // GMAIL username $mail->Password = ""; // GMAIL password $mail->From = $email; $mail->FromName = $name; $mail->Subject = "Contact from the Amberleaf Realty Group Website"; $mail->AltBody = $agentalt; $mail->WordWrap = 50; // set word wrap $mail->MsgHTML($agentbody); $mail->AddReplyTo($email,$name); $mail->AddAddress("some@emailaddress.com","Some Person"); $mail->IsHTML(true); // send as HTML $mail2 = new PHPMailer(); // send email to guest $mail2->IsSMTP(); // set to use STMP $mail2->SMTPAuth = true; // enable SMTP authentication $mail2->SMTPSecure = "ssl"; // sets the prefix to the servier $mail2->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server $mail2->Port = 465; // set the SMTP port $mail2->Username = "sending@emailaddress.com"; // GMAIL username $mail2->Password = ""; // GMAIL password $mail2->From = "some@emailaddress.com"; $mail2->FromName = "Amberleaf Realty Group"; $mail2->Subject = "Property Information from the Amberleaf Realty Group"; $mail2->AltBody = $guestalt; $mail2->WordWrap = 50; // set word wrap $mail2->MsgHTML($guestbody); $mail2->AddReplyTo("some@emailaddress.com","Some Person"); $mail2->AddAddress($email,$name); $mail2->IsHTML(true); // send as HTML if(!$mail->Send()) { // agent message could not be sent echo 3; return; } else { if(!$mail2->Send()) { // guest message could not be sent echo 2; return; } else { echo 1; return; } } } ?>