HTML5 PHP form won't send

I have adapted new fields from a previous form build that worked fine. The client side validation works fine but their seems to be a php issue as the email does not send.

I am still learning PHP and forms so any help would be ace!

Please the relevant code form the from page and the php below;

The Page

    <div id="contact-form" class="clearfix">
        <h1>SWPEE certificate</h1><br>
        //init variables
        $cf = array();
        $sr = false;

            $cf = $_SESSION['cf_returndata'];
            $sr = true;
        <ul id="errors" class="<?php echo ($sr && !$cf['form_ok']) ? 'visible' : ''; ?>">
            <li id="info">There were some problems with your form submission:</li>
            if(isset($cf['errors']) && count($cf['errors']) > 0) :
                foreach($cf['errors'] as $error) :
            <li><?php echo $error ?></li>
        <p id="success" class="<?php echo ($sr && $cf['form_ok']) ? 'visible' : ''; ?>">Thanks you. Your information has been submitted.</p>
        <form method="post" action="process2.php">
            <label for="firstname">First Name: <span class="required">*</span></label>
            <input type="text" id="firstname" name="first name" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['first name'] : '' ?>" placeholder="First Name" required autofocus />

            <label for="surname">Surname: <span class="required">*</span></label>
            <input type="text" id="surname" name="surname" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['surname'] : '' ?>" placeholder="Surname" required autofocus />

            <label for="jobtitle">Job title: <span class="required">*</span></label>
            <input type="text" id="jobtitle" name="job title" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['job title'] : '' ?>" placeholder="Job title" required autofocus />

            <label for="office">Office location:</label>
            <select id="office" name="office">
                <option value="Birmingham" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['office'] == 'Birmingham') ? "selected='selected'" : '' ?>>Birmingham</option>
                <option value="Chippenham" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['office'] == 'Chippenham') ? "selected='selected'" : '' ?>>Chippenham</option>
                <option value="Croyden" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['office'] == 'Croyden') ? "selected='selected'" : '' ?>>Croyden</option>
                <option value="Glasgow" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['office'] == 'Glasgow') ? "selected='selected'" : '' ?>>Glasgow</option>
                <option value="Hornsey" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['office'] == 'Hornsey') ? "selected='selected'" : '' ?>>Hornsey</option>
                <option value="London" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['office'] == 'London') ? "selected='selected'" : '' ?>>London</option>
                <option value="Swanley" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['office'] == 'Swanley') ? "selected='selected'" : '' ?>>Swanley</option>
                <option value="York" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['office'] == 'York') ? "selected='selected'" : '' ?>>York</option>

            <label for="emp_con">Employee or Contractor:</label>
            <select id="emp_con" name="emp_con">
            <option value="Employee" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['cmp_con'] == 'Employee') ? "selected='selected'" : '' ?>>Employee</option>
                <option value="Contractor" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['cmp_con'] == 'Contractor') ? "selected='selected'" : '' ?>>Contractor</option>

            <label for="course_module">Course or Module: <span class="required">*</span></label>
            <input type="text" id="course_module" name="course module" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['course module'] : '' ?>" placeholder="Course or Module name" required autofocus />

            <label for="date">Date Course or Module was completed: <span class="required">*</span></label>
            <input type="text" id="date_completed" name="date completed" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['date completed'] : '' ?>" placeholder="23/7/2012" required autofocus />

            <label for="line_manager">Line Manager: <span class="required">*</span></label>
            <input type="text" id="line_manager" name="line manager" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['line manager'] : '' ?>" placeholder="Line Manager" required autofocus />

            <span id="loading"></span>
            <input type="submit" value="Submit" id="submit-button" />
            <p id="req-field-desc"><span class="required">*</span> indicates a required field</p>
        <?php unset($_SESSION['cf_returndata']); ?>

The Processor (process2.php) I have a dummy email address in here its not just a typo!

//form validation vars
$formok = true;
$errors = array();

//sumbission data
$ipaddress = $_SERVER['REMOTE_ADDR'];
$date = date('d/m/Y');
$time = date('H:i:s');

//form data
$first_name = $_POST['first_name'];
$surname = $_POST['surname'];
$job_title = $_POST['job_title'];
$office = $_POST['office'];
$emp_con = $_POST['emp_con'];
$course_module = $_POST['course_module'];
$date_completed = $_POST['date_completed'];
$line_manager = $_POST['line_manager'];

//validate form data

//validate name is not empty
    $formok = false;
    $errors[] = "You have not entered your first name";

    $formok = false;
    $errors[] = "You have not entered your surname";

    $formok = false;
    $errors[] = "You have not entered a job title";

    $formok = false;
    $errors[] = "You have not entered a course module";

    $formok = false;
    $errors[] = "You have not entered the name of your line manager";

    $formok = false;
    $errors[] = "You have not entered the date you completed your module";

//send email if all is ok
    $headers = "From:" . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

    $emailbody = "<p>You have received a new message from the enquiries form on your website.</p>
                  <p><strong>First Name: </strong> {$first_name} </p>
                  <p><strong>Surname: </strong> {$surname} </p>
                  <p><strong>Job title: </strong> {$job_title} </p>
                  <p><strong>Office: </strong> {$office} </p>
                  <p><strong>Employee or Contractor: </strong> {$emp_con} </p>
                  <p><strong>Course or Module title: </strong> {$course_module} </p>
                  <p><strong>Date Course or Module was completed: </strong> {$date_completed} </p>
                  <p>This message was sent from the IP Address: {$ipaddress} on {$date} at {$time}</p>";

    mail("","SWPEE Certificate form",$emailbody,$headers);


//what we need to return back to our form
$returndata = array(
    'posted_form_data' => array(
        'first_name' => $first_name,
        'surname' => $surname,
        'job_title' => $job_title,
        'office' => $office,
        'emp_con' => $emp_con,
        'course_module' => $course_module,
        'date_completed' => $date_completed,
        'line_manager' => $line_manager
    'form_ok' => $formok,
    'errors' => $errors

//if this is not an ajax request
if(empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) !== 'xmlhttprequest'){
    //set session variables
    $_SESSION['cf_returndata'] = $returndata;

    //redirect back to form
    header('location: ' . $_SERVER['HTTP_REFERER']);



    $formok = false;
    $errors[] = "You have not entered your surname";

Try change $surename to $surname

    $formok = false;
    $errors[] = "You have not entered your surname";

Edit: Wow didn't see how long ago this was posted sorry was just related to my question so had a quick look and noticed an error.

Need Your Help

Comparing two input values in a form validation with AngularJS

forms angularjs validation

I am trying to do a form validation using AngularJS. I am especially interested in comparing two values. I want the user to confirm some data he entered before he continues. Lets say I have the code

Unable to link to ncurses in shared object

c shared ncurses shared-libraries object-files

For some reason I have having an issue compiling a shared object that uses ncurses. Even though I include and link with -lncurses, compiling the .so file fails. Please advise.