Note that there are some explanatory texts on larger screens.

plurals
  1. POCall form submit action from php function on same page doesnt work
    primarykey
    data
    text
    <p>I have made an email sender but it doesn't work. I think function isn't even called. How it's possible to do this? I don't want form to redirect on the other page.</p> <pre><code> &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Mail Sender by midas&lt;/title&gt; &lt;meta content="text/html; charset=utf-8" http-equiv="content-type" /&gt; &lt;/head&gt; &lt;?php if(isset($_POST['submitfunc'])) { submitfunc(); } else //show form ?&gt; &lt;body&gt; &lt;form action="?submitfunc" method="post"&gt; &lt;p&gt; Wyślij jako:&lt;br /&gt; &lt;input name="nadawca" type="text" /&gt;&lt;br /&gt; &lt;br /&gt; Odbiorca:&lt;br /&gt; &lt;input name="odbiorca" type="text" /&gt;&lt;br /&gt; &lt;br /&gt; Temat:&lt;br /&gt; &lt;input name="temat" type="text" /&gt;&lt;br /&gt; &lt;br /&gt; Wiadomość lub kod HTML:&lt;br /&gt; &lt;textarea name="wiadomosc" style="width: 210px; height: 76px;"&gt;&lt;/textarea&gt;&lt;/p&gt; &lt;p&gt; &lt;input type="submit" value="Wyślij" /&gt;&lt;/p&gt; &lt;p&gt; &lt;strong&gt;Autor tej strony nie odpowiada za wiadomości wysłane za pośrednictwem tego skryptu.&lt;/strong&gt;&lt;/p&gt; &lt;/form&gt; &lt;/body&gt; &lt;?php function submitfunc() { if(isset($_POST['nadawca']) and isset($_POST['odbiorca']) and isset($_POST['wiadomosc']) and isset($_POST['temat'])) { $to = $_POST['odbiorca']; $subject = $_POST['temat']; $message = $_POST['wiadomosc']; $headers = 'From: ' . $_POST['nadawca'] . "\r\n" . 'Reply-To: ' . $_POST['nadawca'] . "\r\n" . 'X-Mailer: PHP/' . phpversion(); // postawienie @ wylaczy wyswietlanie bledow przez to wyrazenie $mail_sent = @mail($to, $subject, $message, $headers, '-f ' . $_POST['nadawca']); echo $mail_sent ? "Mail sent" : "Mail failed"; } else{ echo "fail"; } } ?&gt; &lt;/html&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.
    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