title: PHP form won't validate after I linked it with my Localhost(using MySQL and PHP)
body: <p>I'm not sure if I am posting this thread in a right way since I made a mistake in my first post and got few answers which said " This site is for helping people with their code not writing it for them".</p>
  
  <p>Anyways I'm a new coder(not actually, I just use Dreamweaver and edit codes) and I'm facing problems with my form validation(JS, CSS, HTML). When ever I link my form with MySQL, the form will no more validate and just submits the empty fields with NULL.</p>
  
  <p><strong>Javascript</strong> file </p>
  
  <p><a href="https://ajax.googleapis.com/ajax/libs/mootools/1.3.0/mootools-yui-compressed.js" rel="nofollow">https://ajax.googleapis.com/ajax/libs/mootools/1.3.0/mootools-yui-compressed.js</a></p>
  
  <p><strong>CSS</strong> </p>
  
  <p><a href="https://drive.google.com/file/d/0B90yvjWksukydVNZZmU0eGtDSnc/edit?usp=sharing" rel="nofollow">https://drive.google.com/file/d/0B90yvjWksukydVNZZmU0eGtDSnc/edit?usp=sharing</a></p>
  
  <p><strong>HTML</strong> file</p>
  
  <p><a href="https://drive.google.com/file/d/0B90yvjWksukyd2hTRFFvTjBjUUU/edit?usp=sharing" rel="nofollow">https://drive.google.com/file/d/0B90yvjWksukyd2hTRFFvTjBjUUU/edit?usp=sharing</a></p>
  
  <pre><code>&lt;?php require_once('Connections/localhost.php'); ?&gt;
  &lt;?php
  if (!function_exists("GetSQLValueString")) {
  function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
  {
    if (PHP_VERSION &lt; 6) {
      $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
    }
  
    $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  
    switch ($theType) {
      case "text":
        $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
        break;    
      case "long":
      case "int":
        $theValue = ($theValue != "") ? intval($theValue) : "NULL";
        break;
      case "double":
        $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
        break;
      case "date":
        $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
        break;
      case "defined":
        $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
        break;
    }
    return $theValue;
  }
  }
  ?&gt;
  &lt;?php
  // *** Validate request to login to this site.
  if (!isset($_SESSION)) {
    session_start();
  }
  
  $loginFormAction = $_SERVER['PHP_SELF'];
  if (isset($_GET['accesscheck'])) {
    $_SESSION['PrevUrl'] = $_GET['accesscheck'];
  }
  
  if (isset($_POST['email'])) {
    $loginUsername=$_POST['email'];
    $password=$_POST['password'];
    $MM_fldUserAuthorization = "";
    $MM_redirectLoginSuccess = "test_page.php";
    $MM_redirectLoginFailed = "form_signin.php";
    $MM_redirecttoReferrer = false;
    mysql_select_db($database_localhost, $localhost);
  
    $LoginRS__query=sprintf("SELECT Email, Password FROM users WHERE Email=%s AND Password=%s",
      GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
  
    $LoginRS = mysql_query($LoginRS__query, $localhost) or die(mysql_error());
    $loginFoundUser = mysql_num_rows($LoginRS);
    if ($loginFoundUser) {
       $loginStrGroup = "";
  
      if (PHP_VERSION &gt;= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
      //declare two session variables and assign them
      $_SESSION['MM_Username'] = $loginUsername;
      $_SESSION['MM_UserGroup'] = $loginStrGroup;       
  
      if (isset($_SESSION['PrevUrl']) &amp;&amp; false) {
        $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];  
      }
      header("Location: " . $MM_redirectLoginSuccess );
    }
    else {
      header("Location: ". $MM_redirectLoginFailed );
    }
  }
  ?&gt;
  &lt;!doctype html&gt;
  &lt;html lang="en-US"&gt;
  
      &lt;link href="css/contact.css" rel="stylesheet" type="text/css"&gt;
      &lt;link rel="stylesheet" href="css/reset.css"&gt;
      &lt;link rel="stylesheet" href="css/skeleton.css"&gt;
      &lt;link rel="stylesheet" href="css/layout.css"&gt;
  
  &lt;?php
  
  // Set email variables
  $email_to = 'ikhlak.shaikh@yahoo.com';
  $email_subject = 'Form submission';
  
  // Set required fields
  $required_fields = array('firstname', 'lastname', 'username', 'email','password');
  
  // set error messages
  $error_messages = array(
      'firstname' =&gt; 'Please enter a Name to proceed.',
      'lastname' =&gt; 'Please enter a Name to proceed.',
      'email' =&gt; 'Please enter a valid Email Address to continue.',
      'password' =&gt; 'Please enter your password to continue.'
  );
  
  // Set form status
  $form_complete = FALSE;
  
  // configure validation array
  $validation = array();
  
  // check form submittal
  if(!empty($_POST)) {
      // Sanitise POST array
      foreach($_POST as $key =&gt; $value) $_POST[$key] = remove_email_injection(trim($value));
  
      // Loop into required fields and make sure they match our needs
      foreach($required_fields as $field) {       
          // the field has been submitted?
          if(!array_key_exists($field, $_POST)) array_push($validation, $field);
  
          // check there is information in the field?
          if($_POST[$field] == '') array_push($validation, $field);
  
          // validate the email address supplied
          if($field == 'email') if(!validate_email_address($_POST[$field])) array_push($validation, $field);
      }
  
      // basic validation result
      if(count($validation) == 0) {
          // Prepare our content string
          $email_content = 'New Website Comment: ' . "\n\n";
  
          // simple email content
          foreach($_POST as $key =&gt; $value) {
              if($key != 'submit') $email_content .= $key . ': ' . $value . "\n";
          }
  
          // if validation passed ok then send the email
          mail($email_to, $email_subject, $email_content);
  
          // Update form switch
          $form_complete = TRUE;
      }
  }
  
  function validate_email_address($email = FALSE) {
      return (preg_match('/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i', $email))? TRUE : FALSE;
  }
  
  function remove_email_injection($field = FALSE) {
     return (str_ireplace(array("\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:"), '', $field));
  }
  
  ?&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
  &lt;script type="text/javascript"&gt;
  function MM_preloadImages() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
      var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i&lt;a.length; i++)
      if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
  }
  &lt;/script&gt;
  &lt;head&gt;
  &lt;body onLoad="MM_preloadImages('images/misc/x.png')"&gt;
  
  &lt;!-- Contact Form Designed by James Brand @ dreamweavertutorial.co.uk --&gt;
  &lt;!-- Covered under creative commons license - http://dreamweavertutorial.co.uk/permissions/contact-form-permissions.htm --&gt;
  
  &lt;title&gt;Signup|Soleoft&lt;/title&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  
  &lt;link href="css/contact.css" rel="stylesheet" type="text/css" /&gt;
      &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/mootools/1.3.0/mootools-yui-compressed.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" sr="js/form_validation.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  
          var firstnameError = '&lt;?php echo $error_messages['firstname']; ?&gt;';
          var lastnameError = '&lt;?php echo $error_messages['lastname']; ?&gt;';
          var emailError = '&lt;?php echo $error_messages['email']; ?&gt;';
          var usernameError = '&lt;?php echo $error_messages['username']; ?&gt;';
  &lt;/script&gt;
  
  &lt;/head&gt;
  
  &lt;div class="container"&gt;
    &lt;div class='clear'&gt;&lt;/div&gt;
    &lt;a href="index.php"&gt;&lt;img src="images/misc/Capture.PNG" alt="" width="983" height="128" class="container" /&gt;&lt;/a&gt;
    &lt;div class="container1"&gt;
  &lt;h1&gt;Create an Account Today.&lt;/h1&gt;
  &lt;p&gt;&amp;nbsp;&lt;/p&gt;
  &lt;h6&gt;Looking for work? &lt;a href="test_page.php"&gt;Contact Us&lt;/a&gt;. Have an account? Sign In.&lt;/h6&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="container"&gt;
  &lt;div id="formWrap"&gt;
  &lt;div id="form"&gt;
  &lt;?php if($form_complete === FALSE): ?&gt;
  &lt;form ACTION="&lt;?php echo $loginFormAction; ?&gt;" name="signin_form" method="POST" id="signin_form"&gt;&lt;!-- end .row --&gt;&lt;!-- end .row --&gt;
  
      &lt;div class="row"&gt;
      &lt;div class="label"&gt;Email Address&lt;/div&gt;
      &lt;div class="input"&gt;
      &lt;input type="text" id="Email" class="detail" name="email" value="&lt;?php echo isset($_POST['email'])? $_POST['email'] : ''; ?&gt;" /&gt;&lt;?php if(in_array('email', $validation)): ?&gt;&lt;span class="error"&gt;&lt;?php echo $error_messages['email']; ?&gt;&lt;/span&gt;&lt;?php endif; ?&gt;
      &lt;/div&gt;&lt;!-- end .input --&gt;
      &lt;div class="context"&gt;e.g. John@domain.com&lt;/div&gt;
      &lt;!-- end .context --&gt;
    &lt;/div&gt;&lt;!-- end .row --&gt;
  
    &lt;div class="row"&gt;
      &lt;div class="label"&gt;Password&lt;/div&gt;
      &lt;div class="input"&gt;
      &lt;input type="password" id="Password" class="detail" name="password" value="&lt;?php echo isset($_POST['username'])? $_POST['password'] : ''; ?&gt;" /&gt;
  &lt;?php if(in_array('password', $validation)): ?&gt;&lt;span class="error"&gt;&lt;?php echo $error_messages['password']; ?&gt;&lt;/span&gt;&lt;?php endif; ?&gt;
      &lt;/div&gt;&lt;!-- end .input --&gt;
      &lt;div class="context"&gt;e.g. Jsmith&lt;/div&gt;&lt;!-- end .context --&gt;
      &lt;/div&gt;&lt;!-- end .row --&gt;&lt;!-- end .row --&gt;
  
      &lt;div class="submit"&gt;
    &lt;input name="signinbutton" type="submit" class="submit" id="signinbutton" value="Sign up"&gt;
  
    &lt;/div&gt;&lt;!-- end .submit --&gt;
  &lt;/form&gt;
  
  
    &lt;?php else: ?&gt;
  &lt;p style="font-family: 'Segoe UI'; font-size: 24px; font-weight: bold;"&gt;Thank you for your Message!&lt;/p&gt;
  &lt;?php endif; ?&gt;
  &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  
  &lt;script type="text/javascript"&gt;
  setTimeout('ourRedirect()', 5000)
  function ourRedirect() {
      location.href='loggedin.html'   
  }
  
  &lt;/div&gt; 
  &lt;!-- end #form --&gt;
  &lt;/div&gt; &lt;!-- end formWrap --&gt;
  
  
  &lt;/body&gt; 
  &lt;/html&gt;&lt;?php
  mysql_free_result($RegisterUser);
  ?&gt;&lt;?php
  mysql_free_result($RegisterUser);
  ?&gt;
  </code></pre>
  
  <p><strong>CSS</strong> </p>
  
  <pre><code>@charset "utf-8";
  
      body {background: #e9e9e9;
  
      }
  
  #formWrap {
      width: 720px;
      margin-top:30px;
      margin-left:110px;
      background:#fff;
      border:1px solid #f1f1f1;
      -moz-border-radius:20px;
      -moz-box-shadow:2px 2px 5px #999;
      -webkit-border-radius:20px;
      -webkit-box-shadow:2px 2px 5px #999;
      padding: 16px 10px 40px;
  }
  
  
  #form {
      border-top:1px solid #eee
      width:720px;
  }
  
  
  #form .row {
      border-bottom:1px dotted #eee;
      display:block;
      line-height:38px;
      overflow:auto;
      width:100%;
      margin-left:20px;
  }
  
  
  #form .row .label {
      font-size:16px;
      font-weight:bold;
      font-family:"Segoe UI";
      width:180px;
      text-align:right;
      float:left;
      padding-right:10px;
      margin-right:10px;
  }
  
  
  #form .row .input {
      float: left;
      margin-right:18px;
  /*  width:auto; */
      width:285px;
  
  }
  
  
      .detail {
          width:260px;
          font-family:"Segoe UI";
          font-size:13px;
          padding: 7px 8px;
          margin:0;
          display:block;
          border-radius:5px 5px 5px 5px;
          background:#FFF;
          border:1px solid;
  }
  
  
      .detail:focus { 
      outline: none;
      border: 2px solid #7bc1f7;
      box-shadow: 0px 0px 8px #7bc1f7;
      -moz-box-shadow: 0px 0px 8px #7bc1f7;
      -webkit-box-shadow: 0px 0px 8px #7bc1f7;
  }
  
  
  #form .row .context {
      color:#eee;
      font-size:11px;
      font-style:italic;
      line-height;14px;
      font-family:"Segoe UI";
      width:200px;
      float:left;
  }
  
  
  #form .submit {
      font-family:"Segoe UI";
      margin-left:100px;
      font-size:18px;
      text-shadow:1px 1px 1px #999;
      paddig:10px ;
  }
  
  span.error {
      color:#F00;
      display:block;
      font-family:"Segoe UI";
      font-size:12px;
      background-image:url(../images/misc/x.png);
      background-repeat:no-repeat;
      background-position:left 10px;
      padding-left:25px;
  
  
  }
  
  #formWrap h2 {
      font-family: "Segoe UI";
      text-shadow:1px 1px 1px #ccc;
      margin-left:25px;
      color:#333  
  }
  
  .container .clear, body .clear {width: 720p; float: left; clear: both; margin: 20px 0; padding-top:20px; margin:auto; }
  
  .container1 {
      width: 100%;
      font-size: 100%;
      font-family:"Segoe UI";
      font-weight:bold;
      margin-left: auto;
      margin-right: auto;
  
  }
  
  
  h1 {width: 100%; clear: both;  text-align: center; color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.2); font-size:36pt; font-weight: 600;}
  
  h6 {width: 100%; clear: both;  text-align: center; color: #000; text-shadow: 0 1px 1px rgba(0,0,0,.2); font-size:9pt; font-weight: bold; text-shadow:1px 1px 1px #999;}
  </code></pre>