title: How to store input given by user in html form in sql using php
body: <p>This is my PHP code.</p>
  
  <pre><code>&lt;html&gt;&lt;head&gt;
  &lt;title&gt;login.php&lt;/title&gt;
  &lt;link rel = "stylesheet" href="login-style.css"&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div class = "container"&gt;
  &lt;div class = "message"&gt;
  &lt;?php
  define('DB_NAME','mydb');
  define('DB_USER','root');
  define('DB_PASSWORD','');
  define('DB_HOST','127.0.0.1');
  
  $link = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);
  if($link){
      die('could not connect:'. mysql_error());
  }
  $db_selected = mysql_select_db(DB_NAME,$link);
  if(!$db_selected){
      die('can\'t use'.DB_NAME . ': ' . mysql_error());
  }
  $value1 = $_POST['name'];
  $value2 = $_POST['password'];
  $sql = "INSERT INTO Account (username,password) VALUES ('$value1','$value2')";
  
  if(!mysql_query($sql))
  {die('ERROR'.mysql_error());
  }
  mysql_close();
  ?&gt;
  
  &lt;h1&gt;Thank you for logging in &lt;/h1&gt;
  &lt;form action = "form.html"&gt;
  &lt;p class ="submit"&gt;
  &lt;button type ="submit" &gt;
  GO TO FORM
  &lt;/button&gt;
  &lt;/p&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I want to store the data in MySQL but when I run the html code (which i have connected to this php code using action =" name of this file"), no entry is done in database I created, can you tell me what is done wrong and help me to correct it?</p>
  
  <pre><code>&lt;DOCTYPE! html&gt;
  &lt;html lang = "en-US"&gt;
  &lt;head&gt;
  &lt;meta charset = "UTF-8"&gt;
  &lt;title&gt;Sign-In&lt;/title&gt;
  &lt;link rel = "stylesheet" href ="style-sign.css"&gt;
  &lt;script type = "text/javascript"&gt;
  function validateForm(){
  var x = document.forms["forma"]["login"].value;
  if(x == null || x == "")
  { alert("fill the field ");
    return false;
  }
  var y = document.forms["forma"]["password"].value;
  if( y == null || y == "")
  {
  alert("fill the field");
  return false;
  }
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body &gt;
  &lt;div class="container"&gt;
  &lt;div class="login"&gt;
  &lt;h1&gt;Login&lt;/h1&gt;
  &lt;form  name = "forma" method="post" onsubmit="return validateForm()" action = "login.php"&gt;
  &lt;p&gt;
  &lt;input type="text" name="name" value="" placeholder="Username or Email"&gt;
  &lt;/p&gt;
  &lt;p&gt;
  &lt;input type="password" name="password" value="" placeholder="Password"&gt;
  &lt;/p&gt;
  &lt;p class="submit"&gt;
  &lt;input type="submit" name="commit" value="Login" &gt;
  &lt;/p&gt;
  &lt;/form&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>this is my html code which i have connected to this php file ,I am using xampp and using phpmyadmin , I am not getting any error and apache and mysql both are running </p>
  
  <p>help me with this problem </p>