PHP/jQuery Contact Form Not Sending
<p>I have a contact form which is validated using jQuery.</p>

<p>The issues with the jQuery were solved in another question.</p>

<p>However, I can not get the form to work even when i take out the validation and have it as a standalone PHP file with just the HTML form and the PHP to send it.</p>

<p>There is no error. The page just goes to a blank page after pressing submit and not to the message in the code.</p>

<p>Here is the code - I have a feeling it is something very simple!:</p>

<pre><code>&lt;!DOCTYPE HTML&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;?php
if (isset($_POST['submit'])){
}
else {
?&gt;

&lt;meta charset="utf-8" /&gt;

&lt;link href='http://fonts.googleapis.com/css?family=PT+Sans+Narrow' rel='stylesheet' type='text/css'&gt;
&lt;link href='http://fonts.googleapis.com/css?family=Droid+Sans' rel='stylesheet' type='text/css'&gt;
&lt;link rel="stylesheet" href="**REMOVED**/style.css"&gt;


&lt;script type="text/javascript"&gt;
jQuery.noConflict();
jQuery(document).ready(function($) {


function isInt(n) {
return typeof n === 'number' &amp;&amp; n % 1 == 0;
}

// Form validation
$(".darkBtn").click(function(e) {
e.preventDefault();
var email_check = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$/i;
var email = $("form.form_contact .email").val();

var zipCheck = /[A-Z]{1,2}[0-9R][0-9A-Z]? [0-9][ABD-HJLNP-UW-Z]{2}/i;
var zip = $("form.form_contact .zipcode").val();

var phoneCheck = /^\d+$/;
var phone = jQuery("#contact_form .phone").val();
console.log(phone);

var error = "";

if(!email_check.test(email))
{
error = "Please give a valid email address."

}

if(!zipCheck.test(zip))
{
error = "Please give a valid postcode.";
}

if(!phoneCheck.test(phone) || phone.length != 11)
{
error = "Please give a valid phone number.";
}


// No error ? -&gt; Submit
if(error == "")
{
$(".form_error").hide();
$("form#contact_form").submit();
} else {
$(".form_error").empty().text(error);
$(".form_error").show();
}
});
});


&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class="menu_contact"&gt;
&lt;h3&gt;Contact Us&lt;/h3&gt;
&lt;hr /&gt;
&lt;form method="POST" class="form_contact" id="contact_form"&gt;
&lt;label&gt;Title:&lt;/label&gt;
&lt;select class="input" name="title"&gt;
&lt;option value="no"&gt;Please select&lt;/option&gt;
&lt;option value="Mr"&gt;Mr&lt;/option&gt;
&lt;option value="Mrs"&gt;Mrs&lt;/option&gt;
&lt;option value="Miss"&gt;Miss&lt;/option&gt;
&lt;option value="Ms"&gt;Ms&lt;/option&gt;
&lt;/select&gt;
&lt;label&gt;Contact Number:&lt;/label&gt;
&lt;input type="text" class="input phone" placeholder="Your number" name="number"&gt;
&lt;label&gt;First name:&lt;/label&gt;
&lt;input type="text" class="input" placeholder="John" name="fname"/&gt;
&lt;label&gt;Surname:&lt;/label&gt;
&lt;input type="text" class="input" placeholder="Doe" name="sname"/&gt;
&lt;label&gt;Email:&lt;/label&gt;
&lt;input type="email" class="input email" placeholder="something@domain.com" name="email"/&gt;
&lt;label&gt;Postcode:&lt;/label&gt;
&lt;input type="text" class="input zipcode" placeholder="CW3 9SS" name="post"/&gt;
&lt;label&gt;Date of birth:&lt;/label&gt;
&lt;select class="input dateDay" name="day"&gt;
&lt;option&gt;Day&lt;/option&gt;
&lt;option&gt;1&lt;/option&gt;
&lt;option&gt;2&lt;/option&gt;
&lt;option&gt;3&lt;/option&gt;
&lt;option&gt;4&lt;/option&gt;
&lt;option&gt;5&lt;/option&gt;
&lt;option&gt;6&lt;/option&gt;
&lt;option&gt;7&lt;/option&gt;
&lt;option&gt;8&lt;/option&gt;
&lt;option&gt;9&lt;/option&gt;
&lt;option&gt;10&lt;/option&gt;
&lt;option&gt;11&lt;/option&gt;
&lt;option&gt;12&lt;/option&gt;
&lt;option&gt;13&lt;/option&gt;
&lt;option&gt;14&lt;/option&gt;
&lt;option&gt;15&lt;/option&gt;
&lt;option&gt;16&lt;/option&gt;
&lt;option&gt;17&lt;/option&gt;
&lt;option&gt;18&lt;/option&gt;
&lt;option&gt;19&lt;/option&gt;
&lt;option&gt;20&lt;/option&gt;
&lt;option&gt;21&lt;/option&gt;
&lt;option&gt;22&lt;/option&gt;
&lt;option&gt;23&lt;/option&gt;
&lt;option&gt;24&lt;/option&gt;
&lt;option&gt;25&lt;/option&gt;
&lt;option&gt;26&lt;/option&gt;
&lt;option&gt;27&lt;/option&gt;
&lt;option&gt;28&lt;/option&gt;
&lt;option&gt;29&lt;/option&gt;
&lt;option&gt;30&lt;/option&gt;
&lt;option&gt;31&lt;/option&gt;
&lt;/select&gt;
&lt;select class="input dateMonth" name="month"&gt;
&lt;option&gt;Month&lt;/option&gt;
&lt;option&gt;January&lt;/option&gt;
&lt;option&gt;February&lt;/option&gt;
&lt;option&gt;March&lt;/option&gt;
&lt;option&gt;April&lt;/option&gt;
&lt;option&gt;May&lt;/option&gt;
&lt;option&gt;June&lt;/option&gt;
&lt;option&gt;July&lt;/option&gt;
&lt;option&gt;August&lt;/option&gt;
&lt;option&gt;September&lt;/option&gt;
&lt;option&gt;October&lt;/option&gt;
&lt;option&gt;November&lt;/option&gt;
&lt;option&gt;December&lt;/option&gt;
&lt;/select&gt;
&lt;select class="input dateYear" name="year"&gt;
&lt;option&gt;Year&lt;/option&gt;
&lt;option value="1996"&gt;1996&lt;/option&gt;
&lt;option value="1995"&gt;1995&lt;/option&gt;
&lt;option value="1994"&gt;1994&lt;/option&gt;
&lt;option value="1993"&gt;1993&lt;/option&gt;
&lt;option value="1992"&gt;1992&lt;/option&gt;
&lt;option value="1991"&gt;1991&lt;/option&gt;
&lt;option value="1990"&gt;1990&lt;/option&gt;
&lt;option value="1989"&gt;1989&lt;/option&gt;
&lt;option value="1988"&gt;1988&lt;/option&gt;
&lt;option value="1987"&gt;1987&lt;/option&gt;
&lt;option value="1986"&gt;1986&lt;/option&gt;
&lt;option value="1985"&gt;1985&lt;/option&gt;
&lt;option value="1984"&gt;1984&lt;/option&gt;
&lt;option value="1983"&gt;1983&lt;/option&gt;
&lt;option value="1982"&gt;1982&lt;/option&gt;
&lt;option value="1981"&gt;1981&lt;/option&gt;
&lt;option value="1980"&gt;1980&lt;/option&gt;
&lt;option value="1979"&gt;1979&lt;/option&gt;
&lt;option value="1978"&gt;1978&lt;/option&gt;
&lt;option value="1977"&gt;1977&lt;/option&gt;
&lt;option value="1976"&gt;1976&lt;/option&gt;
&lt;option value="1975"&gt;1975&lt;/option&gt;
&lt;option value="1974"&gt;1974&lt;/option&gt;
&lt;option value="1973"&gt;1973&lt;/option&gt;
&lt;option value="1972"&gt;1972&lt;/option&gt;
&lt;option value="1971"&gt;1971&lt;/option&gt;
&lt;option value="1970"&gt;1970&lt;/option&gt;
&lt;option value="1969"&gt;1969&lt;/option&gt;
&lt;option value="1968"&gt;1968&lt;/option&gt;
&lt;option value="1967"&gt;1967&lt;/option&gt;
&lt;option value="1966"&gt;1966&lt;/option&gt;
&lt;option value="1965"&gt;1965&lt;/option&gt;
&lt;option value="1964"&gt;1964&lt;/option&gt;
&lt;option value="1963"&gt;1963&lt;/option&gt;
&lt;option value="1962"&gt;1962&lt;/option&gt;
&lt;option value="1961"&gt;1961&lt;/option&gt;
&lt;option value="1960"&gt;1960&lt;/option&gt;
&lt;option value="1959"&gt;1959&lt;/option&gt;
&lt;option value="1958"&gt;1958&lt;/option&gt;
&lt;option value="1957"&gt;1957&lt;/option&gt;
&lt;option value="1956"&gt;1956&lt;/option&gt;
&lt;option value="1955"&gt;1955&lt;/option&gt;
&lt;option value="1954"&gt;1954&lt;/option&gt;
&lt;option value="1953"&gt;1953&lt;/option&gt;
&lt;option value="1952"&gt;1952&lt;/option&gt;
&lt;option value="1951"&gt;1951&lt;/option&gt;
&lt;option value="1950"&gt;1950&lt;/option&gt;
&lt;option value="1949"&gt;1949&lt;/option&gt;
&lt;option value="1948"&gt;1948&lt;/option&gt;
&lt;option value="1947"&gt;1947&lt;/option&gt;
&lt;option value="1946"&gt;1946&lt;/option&gt;
&lt;option value="1945"&gt;1945&lt;/option&gt;
&lt;option value="1944"&gt;1944&lt;/option&gt;
&lt;option value="1943"&gt;1943&lt;/option&gt;
&lt;option value="1942"&gt;1942&lt;/option&gt;
&lt;option value="1941"&gt;1941&lt;/option&gt;
&lt;option value="1940"&gt;1940&lt;/option&gt;
&lt;option value="1939"&gt;1939&lt;/option&gt;
&lt;option value="1938"&gt;1938&lt;/option&gt;
&lt;option value="1937"&gt;1937&lt;/option&gt;
&lt;option value="1936"&gt;1936&lt;/option&gt;
&lt;option value="1935"&gt;1935&lt;/option&gt;
&lt;option value="1934"&gt;1934&lt;/option&gt;
&lt;option value="1933"&gt;1933&lt;/option&gt;
&lt;option value="1932"&gt;1932&lt;/option&gt;
&lt;option value="1931"&gt;1931&lt;/option&gt;
&lt;option value="1930"&gt;1930&lt;/option&gt;
&lt;option value="1929"&gt;1929&lt;/option&gt;
&lt;option value="1928"&gt;1928&lt;/option&gt;
&lt;option value="1927"&gt;1927&lt;/option&gt;
&lt;option value="1926"&gt;1926&lt;/option&gt;
&lt;option value="1925"&gt;1925&lt;/option&gt;
&lt;option value="1924"&gt;1924&lt;/option&gt;
&lt;option value="1923"&gt;1923&lt;/option&gt;
&lt;option value="1922"&gt;1922&lt;/option&gt;
&lt;option value="1921"&gt;1921&lt;/option&gt;
&lt;option value="1920"&gt;1920&lt;/option&gt;
&lt;option value="1919"&gt;1919&lt;/option&gt;
&lt;option value="1918"&gt;1918&lt;/option&gt;
&lt;option value="1917"&gt;1917&lt;/option&gt;
&lt;option value="1916"&gt;1916&lt;/option&gt;
&lt;option value="1915"&gt;1915&lt;/option&gt;
&lt;option value="1914"&gt;1914&lt;/option&gt;
&lt;option value="1913"&gt;1913&lt;/option&gt;
&lt;/select&gt;
&lt;label&gt;Where did you hear about us:&lt;/label&gt;
&lt;select class="input" name="hear"&gt;
&lt;option value="google"&gt;Google&lt;/option&gt;
&lt;option value="recommendation"&gt;Recommendation&lt;/option&gt;
&lt;option value="email"&gt;Email&lt;/option&gt;
&lt;option value="Magazine"&gt;Magazine&lt;/option&gt;
&lt;option value="Facebook"&gt;Facebook&lt;/option&gt;
&lt;option value="Other"&gt;Other&lt;/option&gt;
&lt;/select&gt;
&lt;div class="form_error" style="display:none;color:red;text-align:center;text-shadow:none;"&gt;&lt;/div&gt;
&lt;input class="darkBtn submit" type="submit" value="Send my message »" name="submit"&gt;
&lt;/form&gt;
&lt;/div&gt;
&lt;?php
} if (isset($_POST['submit'])) {

$to = "**REMOVED**";
$emailfrom = "**REMOVED**";
$subject = "Insurance Quote";
$message="\r\n Title:" . $title . "\r\n First Name:" . $fname . "\r\n Surname:" . $_POST['sname'] . "\r\n Number: " . $_POST['number1'] . "\r\n Email: " . $_POST['email'] . "\r\n Post: " . $_POST['post'] . "\r\n Day: " . $_POST['day'] . "\r\n Month: " . $_POST['year'] . "\r\n Hear: " . $_POST['hear'];
$headers = "From:" . $emailfrom;

if (mail($to,$subject,$message,$headers) ) {
echo "Thankyou for using **REMOVED**";
}
}

?&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>**UPDATE:
When i remove the jQuery validation the page sends perfect.</p>

<p>However, if i keep the jQuery validation in then the page does not do Anything when i press submit.**</p>
