Reputation: 9
i created a website and i'm just beginning with content management, so i installed wordpress with xampp and now adding everything that i made to the wordpress server. the only problem that came up is that i have a regular html formular with an action added that starts the php file when the user sends me the email which works offline. now i copied everything over and i don't get anything. it just sends me to another page without any content in it. so now my question is how do i tell wordpress to start the php file, when the user clicks on submit, send me the email and redirect the user to a success page.
Upvotes: 0
Views: 242
Reputation: 3816
You can check for the submit value and send the email:
A simple form:
<form action="<?php echo site_url(); ?>" method="POST">
<input type="text" name="some_field">
<input type="submit" name="sendmail" value="1">
</form>
Add this to your functions.php:
if ( isset( $_POST['sendmail'] ) ) {
// here the code to send the mail
wp_mail( ... );
// redirect to a specific page
wp_redirect( site_url('email-confirm') );
exit;
}
Usefull links: wp_mail(), wp_redirect()
Upvotes: 1