php contact us form issue
<p>I created a contact us form which should be simple and most importantly secure, so user can't enter code to be executed on the server side:</p>

<pre><code>&lt;?php

$userips = ($_SERVER['X_FORWARDED_FOR']) ? $_SERVER['X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];

$ips = $userips;

// Clean up the input values
foreach($_POST as $key =&gt; $value) {
  if(ini_get('magic_quotes_gpc'))
    $_POST[$key] = stripslashes($_POST[$key]);

  $_POST[$key] = htmlspecialchars(strip_tags($_POST[$key]));
}


// Assign the input values to variables for easy reference
$name = $_POST["name"];
$email = $_POST["email"];
$reason = $_POST["reason"];
$message = $_POST["message"];

mail($to, $subject, $message, $headers);

// Send the email
$to = "test@testsite.com";
$subject = "From: $name . " Reason: " . $reason";
$message = "$message" . "\n\n\n==-   Sent from the website with IP Address: " . $ips . "   -==";;
$headers = "From: $email";



$send_contact=mail($to,$subject,$message,$header);


header("Location: http://www.testsite.com");


// Check, if message sent to your email
// display message "We've recived your information"
// if($send_contact){
// echo "We've recived your contact information";
// }
// else {
// echo "ERROR";
// }
?&gt;
</code></pre>

<p>Will the above code do the job? Or am I missing codes to ensure the security is set in place?</p>

<p><strong>EDIT</strong>
I have the following Jquery script which checks for email validity:</p>

<pre><code>'email' : function() {

    $('body').append('&lt;div id="emailInfo" class="info"&gt;&lt;/div&gt;');

    var emailInfo = $('#emailInfo');
    var ele = $('#email');
    var pos = ele.offset();

    emailInfo.css({
        top: pos.top-3,
        left: pos.left+ele.width()+15
    });

    var patt = /^.+@.+[.].{2,}$/i;

    if(!patt.test(ele.val())) {
        jVal.errors = true;
            emailInfo.html('&lt;img src=theImages/xMark.png title="Please enter a valid email address" alt="Please enter a valid email address" /&gt;').show();
            ele.removeClass('normal').addClass('wrong');                    
    } else {
            emailInfo.html('&lt;img src=theImages/checkMark.gif /&gt;').show();
            ele.removeClass('wrong').addClass('normal');
    }
},
</code></pre>

<p>With the above code, can i leave the ELSE statement blank in the php code?</p>
