Note that there are some explanatory texts on larger screens.

plurals
  1. POcontact form PHP redirect is not working
    text
    copied!<p>I im trying to redirect to my homepage after submitting a message on my contact form, the form sends the email but I get this message:</p> <pre><code>Array ( [name] =&gt; Abdo [company] =&gt; Mediabyrån A&amp;B [email] =&gt; a.el-madhoun@hotmail.com [content] =&gt; Hejsan [contact_to] =&gt; info@web.se ) </code></pre> <blockquote> <p>Warning: Cannot modify header information - headers already sent by (output started at /customers/4/5/a/webelite.se/httpd.www/kontakt.php:3) in /customers/4/5/a/webelite.se/httpd.www/kontakt.php on line 39</p> </blockquote> <p>My contact form;</p> <pre><code>&lt;form action="kontakt.php" method="post"&gt; &lt;p&gt;&lt;input type="text" required="required" id="name" name="name" class="text_input" size="22" /&gt; &lt;label for="name"&gt;Namn *&lt;/label&gt;&lt;/p&gt; &lt;p&gt;&lt;input type="text" required="required" id="company" name="company" class="text_input" size="22" /&gt; &lt;label for="company"&gt;Företag *&lt;/label&gt;&lt;/p&gt; &lt;p&gt;&lt;input type="email" required="required" id="email" name="email" class="text_input" size="22" /&gt; &lt;label for="email"&gt;Epost *&lt;/label&gt;&lt;/p&gt; &lt;p&gt;&lt;textarea required="required" name="content" class="textarea" cols="30" rows="5"&gt;&lt;/textarea&gt;&lt;/p&gt; &lt;p&gt;&lt;button type="submit" class="button white"&gt;&lt;span&gt;Skicka&lt;/span&gt;&lt;/button&gt;&lt;/p&gt; &lt;input type="hidden" value="info@web.se" name="contact_to"/&gt; &lt;/form&gt; </code></pre> <p>and this is my PHP:</p> <pre><code>&lt;?php echo $name = $_POST['name']; echo $company = $_POST['company']; echo $email = $_POST['email']; echo $content = $_POST['content']; $mail_to = 'info@webelite.se'; $subject = 'Lilla form'.$name; $body_message = 'From: '. $name . "\n"; $body_message .= 'company: '. $company . "\n"; $body_message .= 'E-mail: '. $email ."\n"; $body_message .= 'Message: '. $content; $headers = 'From: '. $mail_name . "\r\n"; $headers .= 'Reply-To: '. $email ."\r\n"; $success = mail($mail_to, $subject, $body_message, $headers); echo "&lt;pre&gt;"; print_r($_POST); header('Location:mydomain'); ?&gt; </code></pre> <p>I also tried using if </p> <pre><code>($success){ print "&lt;meta http-equiv=\"refresh\" content=\"0;URL=YOUR_PAGE_HERE.html\"&gt;"; </code></pre> <p>This worked but I got a ugly half a second flash between hitting submit and being redirected.</p> <p>All help is appriciated.</p> <p>Thank you </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