Note that there are some explanatory texts on larger screens.

plurals
  1. POsend email button not working, either opens desired url or sends email, not both simultaneously
    primarykey
    data
    text
    <p>i'm stuck in between the two desired functions which I can't manage to occur simultaneously; I have an email submission form and I need it to redirect the user to a thank you page after hitting the "Submit" button. I'm providing you with 3 html alternatives and 1 php file.</p> <p>When the html is like this, the email gets sent but the redirection doesn't work.</p> <pre><code> &lt;form id="contact_form" action="mailer.php" method="post" enctype="text/plain"&gt; &lt;div class="message" style="display:none"&gt;&lt;div id="contact_alert" class="alert"&gt;&lt;/div&gt;&lt;/div&gt; &lt;label for="name"&gt;Name:&lt;/label&gt; &lt;input type="text" name="name" id="name" class="full-width help" title="Insert your name" /&gt; &lt;label for="email"&gt;Email:&lt;/label&gt; &lt;input type="email" name="email" id="email" class="full-width help" title="Insert your email" /&gt; &lt;label for="message"&gt;Message:&lt;/label&gt; &lt;textarea name="message" id="message" cols="30" rows="7" class="full-width help" title="Insert your message"&gt;&lt;/textarea&gt; &lt;input type="submit" value="Submit" class="button" /&gt; &lt;/form&gt; </code></pre> <p>When i change the last line to this, it sends the email again but redirection still doesn't work:</p> <pre><code> &lt;form id="contact_form" action="mailer.php" method="post" enctype="text/plain"&gt; &lt;div class="message" style="display:none"&gt;&lt;div id="contact_alert" class="alert"&gt;&lt;/div&gt;&lt;/div&gt; &lt;label for="name"&gt;Name:&lt;/label&gt; &lt;input type="text" name="name" id="name" class="full-width help" title="Insert your name" /&gt; &lt;label for="email"&gt;Email:&lt;/label&gt; &lt;input type="email" name="email" id="email" class="full-width help" title="Insert your email" /&gt; &lt;label for="message"&gt;Message:&lt;/label&gt; &lt;textarea name="message" id="message" cols="30" rows="7" class="full-width help" title="Insert your message"&gt;&lt;/textarea&gt; &lt;a href="thank-you"&gt;&lt;input type="submit" value="Submit" class="button" /&gt;&lt;/a&gt; &lt;/form&gt; </code></pre> <p>And finally when I change the last line to this, the redirection works but no email gets sent.</p> <pre><code> &lt;form id="contact_form" action="mailer.php" method="post" enctype="text/plain"&gt; &lt;div class="message" style="display:none"&gt;&lt;div id="contact_alert" class="alert"&gt;&lt;/div&gt;&lt;/div&gt; &lt;label for="name"&gt;Name:&lt;/label&gt; &lt;input type="text" name="name" id="name" class="full-width help" title="Insert your name" /&gt; &lt;label for="email"&gt;Email:&lt;/label&gt; &lt;input type="email" name="email" id="email" class="full-width help" title="Insert your email" /&gt; &lt;label for="message"&gt;Message:&lt;/label&gt; &lt;textarea name="message" id="message" cols="30" rows="7" class="full-width help" title="Insert your message"&gt;&lt;/textarea&gt; &lt;a href="thank-you"&gt;&lt;input type="button" value="Submit" class="button" /&gt;&lt;/a&gt; &lt;/form&gt; </code></pre> <p>This is the php file:</p> <pre><code>&lt;?php $to = "info@domain.com"; $subject = "Hi Nick, this is ".$_POST['name']; $name_field = $_POST['name']; $email_field = $_POST['email']; $message = $_POST['message']; $headers = 'From: '.$_POST['email'].'' . "\r\n" . 'Reply-To: '.$_POST['email'].'' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $body = $message; mail($to, $subject, $body, $headers ); header('Location: http://www.domain.com/thank-you') ; ?&gt; </code></pre> <p>Any help will be highly appreciated. Thanks!</p>
    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