Is there a way where if someone pushes a link it would send me an automated message? This is the only code I found. Where would i add this code?
<form action="" method="post">
<input type="submit" value="Send details to embassy" />
<input type="hidden" name="button_pressed" value="1" />
</form>
<?php
if(isset($_POST['button_pressed']))
{
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "rn" .
'Reply-To: webmaster@example.com' . "rn" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
echo 'Email Sent.';
}
?>
PHP is executed only on the server side, you will need some Javascript to get the message to the server to make the mail send that is the first part of the code below. The second part is the PHP that will handle the sending.
Add this code to your
functions.php
file and place the HTML wherever you want the button.If you need more this is basically a copy of the code here: https://codex.wordpress.org/AJAX_in_Plugins