title: how to enter data enter by user in form in mysql database
body: <p>I have already created database and table in it.But it is showing an error "input data failed"</p>
  
  <p>the code of reg form is as follow
  Code of form login2.php:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Login Form&lt;/title&gt;
  &lt;link rel="stylesheet" href="style.css" type="text/css" media="screen, projection" /&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id="div-regForm"&gt;
  &lt;div class="form-title" align ="center"&gt;VIDEO CHAT &lt;/div&gt;
  &lt;br&gt;&lt;/br&gt;
  &lt;div class="form-sub-title" align="center"&gt;If already registered&lt;/div&gt;
  &lt;P align="center"&gt;
  &lt;td&gt;&lt;input type="submit" class="blueButton" value="Sign in" align="right"/&gt;
  &lt;/P&gt;
  &lt;br&gt;&lt;/br&gt;
  &lt;div class="form-title"&gt;For New User&lt;/div&gt;
  &lt;div class="form-title"&gt;Sign Up&lt;/div&gt;
  &lt;div class="form-sub-title"&gt;It's free and anyone can join&lt;/div&gt;
  
  &lt;form id="regForm" action="validate_login.php" method="post"&gt;
  &lt;table&gt;
  &lt;tbody&gt;
  &lt;tr&gt;
  
      &lt;td&gt;&lt;label for="fname"&gt;First Name:&lt;/label&gt;&lt;/td&gt;
      &lt;td&gt;&lt;div class="input-container"&gt;
      &lt;input name="fname" id="fname" type="text" /&gt;
      &lt;/div&gt;&lt;/td&gt;
  
  &lt;/tr&gt;
  &lt;tr&gt;
  
      &lt;td&gt;&lt;label for="lname"&gt;Last Name:&lt;/label&gt;&lt;/td&gt;
      &lt;td&gt;&lt;div class="input-container"&gt;
      &lt;input name="lname" id="lname" type="text" /&gt;
      &lt;/div&gt;&lt;/td&gt;
  
  &lt;/tr&gt;
  &lt;tr&gt;
  
      &lt;td&gt;&lt;label for="email"&gt;Your Email:&lt;/label&gt;&lt;/td&gt;
      &lt;td&gt;&lt;div class="input-container"&gt;
      &lt;input name="email" id="email" type="text" /&gt;
      &lt;/div&gt;&lt;/td&gt;
  
  &lt;/tr&gt;
  &lt;tr&gt;
  
      &lt;td&gt;&lt;label for="npass"&gt;New Password:&lt;/label&gt;&lt;/td&gt;
      &lt;td&gt;&lt;div class="input-container"&gt;
      &lt;input name="npass" id="npass" type="password" /&gt;
      &lt;/div&gt;&lt;/td&gt;
  
  &lt;/tr&gt;
  &lt;tr&gt;
  
      &lt;td&gt;&lt;label for="cpass"&gt;Confirm Password:&lt;/label&gt;&lt;/td&gt;
      &lt;td&gt;&lt;div class="input-container"&gt;
      &lt;input name="cpass" id="cpass" type="password" /&gt;
      &lt;/div&gt;&lt;/td&gt;
  
  &lt;/tr&gt;
  &lt;tr&gt;
  
      &lt;td&gt;&lt;label for="sex-select"&gt;I am:&lt;/label&gt;&lt;/td&gt;
      &lt;td&gt;
      &lt;div class="input-container"&gt;
      &lt;select name="sex-select" id="sex-select"&gt;
      &lt;option value="0"&gt;Select Sex:&lt;/option&gt;
      &lt;option value="1"&gt;Female&lt;/option&gt;
      &lt;option value="2"&gt;Male&lt;/option&gt;
      &lt;/select&gt;
  
      &lt;/div&gt;
      &lt;/td&gt;
  &lt;/tr&gt;
      &lt;td&gt;
  
      &lt;div class="input-container"&gt;
  
  &lt;tr&gt;
  
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
      &lt;td&gt;&lt;input type="submit" class="greenButton" value="Sign Up"  value="Sent" /&gt;
      &lt;img id="loading" src="img/ajax-loader.gif" alt="working.." /&gt;
      &lt;/td&gt;
  
  &lt;/tr&gt;
  
  &lt;/tbody&gt;
  &lt;/table&gt;
  
  &lt;/form&gt;
  
  &lt;div id="error"&gt;
  &amp;nbsp;
  &lt;/div&gt;
  
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>to enter data in database code validate_login.php:</p>
  
  <p>`</p>
  
  <pre><code>&lt;?php
  
  // Grab User submitted information
  $db_host= "localhost";
  $db_user = "root";
  $db_pass = "";
  $db_name = "testdb";
  
  @mysql_connect("$db_host", "$db_user", "$db_pass")
  or die("Could not connect to MySQL server!");
  
  /*@mysql_select_db("$db_name") or die("No DATABASE");
  
  echo"hi how r u";*/
  $fname = $_POST["fname"];
  $lname = $_POST["lname"];
  $email = $_POST["email"];
  $npass = $_POST["npass"];
  $cpass = $_POST["cpass"];
  $gender = $_POST["sex-select"];
  
  
  // Select the database to use
  @mysql_select_db("testdb")
  or die("Could not select database!");
  
  $order = "Insert INTO 'data_user'
              (fname, lname, email, npass, cpass, sex-select)
              VALUES
              ('$fname',
              '$lname','$email','$npass', '$cpass','$gender')";
              $result = mysql_query($order);  //order executes
  if($result){
      echo("&lt;br&gt;Input data is succeed");
  } else{
      echo("&lt;br&gt;Input data is fail");
  }
  ?&gt;
  </code></pre>
  
  <p>tell me the solution asap</p>