Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your JavaScript is not the best. You shouldn't be using it inline like you are (e.g. with the <code>onsubmit</code> attribute). Instead, it should be unobtrusive so your form should work even if JavaScript is not enabled in the user's browser. An example of which:</p> <pre><code>&lt;form action="editor.php" method="post" id="contact-form"&gt; &lt;div&gt; &lt;label for="to"&gt;To:&lt;/label&gt; &lt;input type="text" name="to" id="to" /&gt; &lt;/div&gt; &lt;div&gt; &lt;label for="subject"&gt;Subject:&lt;/label&gt; &lt;input type="text" name="subject" id="subject" /&gt; &lt;/div&gt; &lt;div&gt; &lt;label for="message"&gt;Message:&lt;/label&gt; &lt;textarea name="message" id="message"&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;div&gt; &lt;input type="submit" name="send" value="Send" /&gt; &lt;/div&gt; &lt;/form&gt; &lt;div id="response"&gt;&lt;/div&gt; &lt;script src="jquery.js"&gt;&lt;/script&gt; &lt;script&gt; $(document).ready(function() { $('#contact-form').submit(function() { var action = $(this).attr('action'); var data = $(this).serialize(); $.post(action, data, function(response) { $('#response').html(response); }); return false; }); }); &lt;/script&gt; </code></pre> <p>The above will see your form still submit to <strong>editor.php</strong> if JavaScript is not available, but if JavaScript <em>is</em> available, then the JavaScript block will pick up for the form submission, and instead post it using AJAX rather than redirect to <strong>editor.php</strong>.</p> <p>If you're wanting to also send test emails, I'd include a checkbox instead with the name <code>test</code>, and if it's checked change the logic in your form handler (in this case <strong>editor.php</strong>) rather than having an entirely different script. At the simplest, it would look like this:</p> <pre><code>&lt;?php $to = $_POST['to']; $subject = $_POST['subject']; $message = $_POST['message']; if (isset($_POST['test'])) { // do something // maybe set $to to something different } if (mail($to, $subject, $message)) { echo 'Sent'; } else { echo 'Not sent'; } </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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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