Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could try something like this:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;ul id="awesome-menu"&gt; &lt;li&gt; &lt;form action="emailAndRedirect.php" id="ninja" method="post"&gt; &lt;input type="hidden" name="name" value="ninja" /&gt; &lt;/form&gt; &lt;a href="javascript:void" onclick="formSubmit('ninja')" class="ninja"&gt;Ninja&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;form action="emailAndRedirect.php" id="ninja" method="post"&gt; &lt;input type="hidden" name="name" value="zombie" /&gt; &lt;/form&gt; &lt;a href="javascript:void" onclick="formSubmit('zombie')" class="zombie"&gt;Zombie&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;script type="text/javascript"&gt; function formSubmit(name) { if (name == 'ninja') { document.getElementById("ninja").submit(); } else if (name == 'zombie') { document.getElementById("zombie").submit(); } } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And in your php:</p> <pre><code>&lt;?php $url = //url of the page you wan t if (isset($_POST['name'])) { $name = $_POST['name']; if ($name == 'ninja') { $email = 'ninja@example.com'; } else if ($name == 'zombie') { $email = 'zombie@example.com'; } } $to = $email; $subject = 'You have a visitor'; $message = 'hello I am here to see $name'; $headers = 'From: webmaster@site.com' . "\r\n" . 'Reply-To: webmaster@site.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); header('Location: $url#$name'); ?&gt; </code></pre> <p>Edit: Thjs uses javascript, so you would be reliant on it. With a javascript form submit function you would be able to keep the same links and styling and still submit the forms.</p>
    singulars
    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.
 

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