Questions
- Assuming that I wanted to put all the code in a custom page like
page-contact.php
how can I structure my code so I can receive email? the code works in other PHP projects, but getting an error in a WordPress environment - Why am I getting an error that the page cannot be found when all i need is the code from the page to handle the form?
Background
I did read another source by Sitepoint about about WordPress emails but this is a tiny project and I just need this to work according to how this project is setup.
In another PHP project I had the form action to be send according to what is written in _contactform.php
<form action="_contactform.php" method="post" name='submitform'>
it works fine there. But when I reused the code in a WordPress project I then got an error that the page did not exist as it seemed to try to direct the user to the url
http://example.com/contact/_contactform.php
So rather than have the action be the _contactform.php
I think I can just put the code in the same page but how would I wrap it, etc?
The php file for the form starts with this
<?php
/* Set e-mail recipient */
$orderemail = "[email protected]";
$name = check_input($_POST['name']);
$email = check_input($_POST['email']);
$address = check_input($_POST['address']);
$message = "
Hello!
Your contact form has been submitted by:
Name: $name
E-mail: $email
Address:
$address
End of message
";
/* Send the message using mail() function */
mail($orderemail, $subject, $message);