Note that there are some explanatory texts on larger screens.

plurals
  1. POContact Form not working [PHP / AJAX]
    primarykey
    data
    text
    <p>When I test it I get a popup saying its submitting, but I also get a message from the ajax part saying there's an error, even though all the contents come to me by email successfully.</p> <p>I think one problem is that there are two different submit messages coming from the both the PHP and the AJAX. Is the PHP needed then? The help would be greatly appreciated.</p> <p><strong>UPDATE:</strong></p> <p>The error message I get is the error response from the ajax after submit, saying "Error something wrong." I also get a pop up saying it was submitted correctly with is the echo from the PHP. </p> <p><em><strong></em></strong><em>UPDATE</em><strong><em>*</em>*</strong> Live Version: <a href="http://pieceofmedesigns.com/test/contact.html" rel="nofollow">http://pieceofmedesigns.com/test/contact.html</a></p> <p>Here is the AJAX:</p> <pre><code>$(function(){ $("#Submit").click(function(){ $.ajax({type:'POST', url: './php/mailer.php', data:$('#frmContact').serialize(), success: function(response) { $("#spanMessage").html('Please Wait...'); if(parseInt(response)&gt;1) { $("#spanMessage").html('&lt;div class="alert alert-success"&gt;&lt;button type="button" class="close" data-dismiss="alert"&gt;&amp;times;&lt;/button&gt;&lt;strong&gt;Well done!&lt;/strong&gt; Your message has been sent.&lt;/div&gt;'); } else{ alert(response); $("#spanMessage").html('&lt;div class="alert alert-error"&gt;&lt;button type="button" class="close" data-dismiss="alert"&gt;&amp;times;&lt;/button&gt;&lt;strong&gt;Error! &lt;/strong&gt; Somthing Wrong&lt;/div&gt;'); } }}); }); </code></pre> <p>Here is the PHP Mailer:</p> <pre><code>&lt;?php session_start(); if(isset($_POST['Submit'])) { $youremail = 'myemail@gmail.com'; $fromsubject = 'Test Email'; $txtName = $_POST['txtName']; $txtEmail = $_POST['txtEmail']; $txtSubject = $_POST['txtSubject']; $txtText = $_POST['txtText']; $to = $youremail; $mailsubject = 'Masage recived from'.$fromsubject.' Contact Page'; $body = $fromsubject.' The person that contacted you is '.$txtName.' E-mail: '.$txtEmail' Message: '.$txtText.' |---------END MESSAGE----------|'; echo "Thank you fo your feedback. I will contact you shortly if needed.&lt;br/&gt;Go to &lt;a href='/index.php'&gt;Home Page&lt;/a&gt;"; mail($to, $subject, $body); } else { echo "You must write a message. &lt;/br&gt; Please go to &lt;a href='/contact.php'&gt;Contact Page&lt;/a&gt;"; } ?&gt; </code></pre> <p>Here is the form:</p> <pre><code>&lt;form action="" method="post" id="frmContact"&gt; &lt;h5&gt;Whats your Name?&lt;/h5&gt; &lt;input name="txtName" type="text" class="txbx" value="Name" /&gt;&lt;br /&gt; &lt;h5&gt;Whats your Email?&lt;/h5&gt; &lt;input name="txtEmail" type="text" class="txbx" value="Email" /&gt;&lt;br /&gt; &lt;h5&gt;Email Subject?&lt;/h5&gt; &lt;input name="txtSubject" type="text" class="txbx" value="Subject" /&gt;&lt;br /&gt; &lt;div class="erabox"&gt; &lt;h5&gt;Message to us&lt;/h5&gt; &lt;textarea name="txtText" cols="" rows="" class="txbx era" value="Message" &gt;&lt;/textarea&gt; &lt;br /&gt; &lt;input name="" type="button" class="sendbtn" value="Send Message" align="left" id="btnSend"/&gt; &lt;/form&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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