There are a few things wrong here.
Let's start from the top and with your conditional statement (and work our way down).
if (isset($_POST['submit'])){...}
Your submit button <input type="submit" value="submit" id="submit"> does not have a name attribute for it.
- You may be relying on an "id" alone, which won't work, it needs the "name" attribute.
Modify it so that it reads as:
<input type="submit" name="submit" value="submit" id="submit">
- Since it's not named, anything inside that conditional statement will not execute.
Then you're using mysqli_real_escape_string() which theoretically requires the connection be passed to that function.
I.e.:
$Name = mysqli_real_escape_string($connection,$Name);
and do the same for the rest; assuming you are interacting with a database.
However, it's unclear whether you are indeed interacting with your database or not, so if you're not interacting with it, remove all of those mysqli_real_escape_string from your POST arrays.
I.e.:
$Name = $_POST['Name'];
and do the same for the others.
You're also missing POST as the method in your form:
<form action="action_page.php" name="myform">
which defaults to GET when omitted. Therefore, change it to:
<form action="action_page.php" name="myform" method="post">
To then check if mail has been sent, change
mail($webEmail,$email_subject,$email_body,$headers);
to
if(mail($webEmail,$email_subject,$email_body,$headers)){
echo "Sent";
}
If you see "Sent", then mail would have done its job. If no mail is received, check your Spam. Or, your server could be blacklisted.
Make sure that you do have access to using mail().
You should also make sure that all inputs have been filled using a conditional empty().
I.e.:
if(!empty($_POST['Name'])){
// $Name = mysqli_real_escape_string($Name);
$Name = $_POST['Name'];
}
Add error reporting to the top of your file(s) which will help find errors.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// rest of your code
Sidenote: Error reporting should only be done in staging, and never production.
Footnotes:
I don't know what these are used for onfocus="this.value='';" so, if you've got some JS/Ajax happening somewhere, you'll need to check those.
- If they're not used for anything, you can remove those.
You should also try removing value="Name" and for the others as well, just in case.
Sidenote:
If you're still getting a 404 error, then try putting your PHP on top and your HTML form below that, and inside the same file with a .php extension, and doing:
<form action="" name="myform" method="post">
using action="" as the action to take place on the same page.
Additional footnote:
I noticed in a comment you placed in another answer:
"I added header( 'Location: lizbethmcgee.com/pages/Contact.php'; ) ;"
First, make sure you're not outputting before header.
Plus, you should also include a full http:// call and exit;:
header("Location: http://www.lizbethmcgee.com/pages/Contact.php");
exit;
to avoid further execution of code that may be present below that, should there contain any.
As AdamT stated in a comment:
Sending a mail with the php mail command, there is no guarantee that the mail will arrive to the inbox you send it to. As mentioned, there are lots of spammers out there, and unfortunately, a heavy degree of spam filtering. If you really want to have a better chance at getting the mail delivered, you should contact GoDaddy and ask them how you can set up SMTP emailing for your account.
mysqli_real_escape_stringfunction if you are not sending your data to sql?