Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP send email issues from ajax/jquery
    text
    copied!<p>I'm not the best at PHP and i'm struggling with what I imagine should be a pretty basic script to send a contact form in an email.</p> <p>My jquery trigger script is as follows - </p> <pre><code>data_html = "name="+ names + "&amp;phone_number=" + phone + "&amp;email_address="+ email_address + "&amp;arrival_date=" + arrival + "&amp;nights=" + nights + "&amp;adults=" + adults+ "&amp;children=" + children + "&amp;rooms=" + rooms + "&amp;notes=" + notes; if (error == false){ $('.error').fadeOut(500); $.ajax({ type: 'POST', url: 'sendMail.php', data: data_html, success: function(msg){ if (msg == 'sent'){ alert("sent") $('#contact-form').fadeOut(); $('#success').fadeIn(); $('#success').html('Your request has been sent, we will respond to you shortly - any issues please call us on 01539 724468') ; $('#name').val(''); $('#phone').val(''); $('#emailAd').val(''); $('#arrival').val(''); $('#notes').val(''); }else{ alert("not sent") $('#contact-form').fadeOut(); $('#success').fadeIn(); $('#success').html('Mail Error. Please Try Again.!') ; setTimeout("$('#success').fadeOut(); $('#contact-form').fadeOut();)",5000) ; } } </code></pre> <p>});</p> <p>My php script consists of the following - </p> <pre><code>&lt;?php $name = $_POST['name']; $phone = $_POST['phone_number']; $email = $_POST['email_address']; $arrival = $_POST['arrival_date']; $nights = $_POST['nights']; $adults = $_POST['adults']; $children = $_POST['children']; $rooms = $_POST['rooms']; $notes = $_POST['notes']; $to ='chunk_pd@yahoo.co.uk'; $message = ""; $message .= "Booking Request from Sundial Website&lt;br&gt;\n&lt;br&gt;\n"; $message .= "*Name: " . htmlspecialchars($name, ENT_QUOTES) . "&lt;br&gt;\n"; $message .= "*Email: " . htmlspecialchars($email, ENT_QUOTES) . "&lt;br&gt;\n"; $message .= "*Phone Number: " . htmlspecialchars($phone, ENT_QUOTES) . "&lt;br&gt;\n"; $message .= "Arrival Date: " . htmlspecialchars($arrival, ENT_QUOTES) . "&lt;br&gt;\n"; $message .= "No of Nights: " . htmlspecialchars($nights, ENT_QUOTES) . "&lt;br&gt;\n"; $message .= "Adults: " . htmlspecialchars($adults, ENT_QUOTES) . "&lt;br&gt;\n"; $message .= "Children: " . htmlspecialchars($children, ENT_QUOTES) . "&lt;br&gt;\n"; $message .= "Rooms: " . htmlspecialchars($rooms, ENT_QUOTES) . "&lt;br&gt;\n"; $message .= "Notes: " . htmlspecialchars($notes, ENT_QUOTES) . "&lt;br&gt;\n"; $headers = "MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: \"" . $name . "\" &lt;" . $email . "&gt;\r\n"; $headers .= "Reply-To: " . $email . "\r\n"; $message = utf8_decode($message); mail($to, "Booking Request from Sundial Website", $message, $headers); if ($message){ echo 'sent'; }else{ echo 'failed'; } ?&gt; </code></pre> <p>Can anyone help or offer an alternate method? The files are here if you want to see them live (http://www.offthecuffdesign.co.uk/chilli/) and (http://www.offthecuffdesign.co.uk/chilli/sendMail.php)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload