How do I call the WP_MAIL function from a page which has a form?
I would like to create a form in a page, and by pressing "Send" activate a function in the functions.php file, so the mail gets sent AND returning to a page where the form information is presented along with confirmation that the mail was actually sent.
Anybody
This is the form:
<form action = "<?php $_PHP_SELF ?>" method = "GET">
Name: <input type = "text" name = "name" />
Age: <input type = "text" name = "age" />
<input type = "submit" />
</form>
Catching this in the content page does not work, should this be placed in the functions.php?
<?php
if( $_GET["name"] || $_GET["age"] ) {
echo "Welcome ". $_GET['name']. "<br />";
echo "You are ". $_GET['age']. " years old.";
exit();
}
?>
POST
form, and hook intoinit
, check if the form is submitted by checkingisset( $_POST['SUBMIT_BTN_NAME_HERE'] )
. Also use nonces as they are good for security.