404 Error with PHP send form

I’ve recently put my first site online - https://glaucomaspecialistsofsanfrancisco.com/
The issue I’m having is that after filling out the contact form and hitting send, the console throws a 404 error and no email is sent.

html -

<form id="my_form" onsubmit="submitForm(); return false;">
                                           <p> <label>First Name</label>
                                              <input type="text" name="first_name" id="firstName" required> </p>
                                              <p> <label>Last Name</label>
                                                <input type="text" name="last_name" id="lastName" required> </p>
                                                <p> <label>Phone Number</label>
                                                  <input type="text" name="phone_number" id="phoneNumber" required> </p>
                                                  <p> <label>Email Address</label>
                                                    <input type="email" name="email_address" id="emailAddress" required> </p>
                                                    <p class="full"> <label>Message</label>
                                                      <textarea name="message" rows="5" id="message" required></textarea> </p>
                                                      <p class="full">
                                                        <button id="button" type="submit" value="Submit Form"><span id="status"></span>Email</button>



if( isset($_POST['name']) && isset($_POST['lastName']) && isset($_POST['phoneNumber']) && isset($_POST['emailAddress']) && isset($_POST['message']) ){
	$name = $_POST['name'];
  $lastName = $_POST['lastName'];
  $phoneNumber = $_POST['phoneNumber'];
	$emailAddress = $_POST['emailAddress'];
	$message = nl2br($_POST['message']);
	$to = 'irene@glaucomaspecialistsofsanfrancisco.com';
	$from = $emailAddress;
	$subject = 'Schedule Inquiry';
	$message = "<b>Name:</b> '.$name.' <b>LastName:</b> '.$lastName.' <br><b>Phone:</b> '.$phoneNumber' <b>Email:</b> '.$emailAddress.' <p>'.$message.'</p>";
	$headers = 'From: $from\n';
	$headers .= 'MIME-Version: 1.0\n';
	$headers .= 'Content-type: text/html; charset=iso-8859-1\n';
	if( mail($to, $subject, $message, $headers) ){
		echo "success";
	} else {
		echo "The server failed to send the message. Please try again later.";

JS -

function _(id){ return document.getElementById(id); }
function submitForm(){
	_("button").disabled = true;
	_("status").innerHTML = 'please wait...';
	var formdata = new FormData();
	formdata.append( "firstName", _("firstName").value );
  formdata.append( "lastName", _("lastName").value );
	formdata.append( "phoneNumber", _("phoneNumber").value );
  formdata.append( "emailAddress", _("emailAddress").value );
  formdata.append( "message", _("message").value );
	var ajax = new XMLHttpRequest();
	ajax.open( "POST", "index.php" );
	ajax.onreadystatechange = function() {
		if(ajax.readyState == 4 && ajax.status == 200) {
			if(ajax.responseText == "success"){
				_("my_form").innerHTML = '<h2>Thank you '+_("name").value +', your message has been sent.</h2>';
			} else {
				_("status").innerHTML = ajax.responseText;
				_("button").disabled = false;
	ajax.send( formdata );

Thank you for the input Randall. You were completely right about (“POST”, “index.php”), just needed to correct that stupid mistake on my end. I’m no longer receiving the error message, however, it seems the info from the contact form is still not being sent to the designated address. I have checked in Cpanel to verify it’s the correct address. Not sure if my code is missing something.

I am not receiving either the success or the error message I put in the php

Your if statement is checking for a field name from the form which does not exist in the formdata object you submit to contact.php

You just need to compare your form fields submitted and the form fields you are checking in your if statement.

Randall you’re a gentleman and a scholar, thank you for your help.