title: form posting to database
body: <p>I have created a form and I'm trying to post data to MySQL databasem, but after submitting the form i am getting the following error..</p>
  
  <blockquote>
    <p>Notice: Undefined index: month in C:\xampp\htdocs\auto\insert_ac.php on line 14<br>
    Notice: Undefined index: listner_name in C:\xampp\htdocs\auto\insert_ac.php on line 15<br>
    Notice: Undefined index: rj_name in C:\xampp\htdocs\auto\insert_ac.php on line 16<br>
    Notice: Undefined index: channel in C:\xampp\htdocs\auto\insert_ac.php on line 17<br>
    Notice: Undefined index: year in C:\xampp\htdocs\auto\insert_ac.php on line 18<br>
    Notice: Undefined index: country in C:\xampp\htdocs\auto\insert_ac.php on line 19  </p>
  </blockquote>
  
  <p>When i check a blank row entry inserted in to my database</p>
  
  <pre><code>&lt;?php
  
  $host="localhost"; // Host name
  $username="root"; // Mysql username`
  $password=""; // Mysql password
  $db_name="auto"; // Database name
  $tbl_name="song_request"; // Table name
  
  // Connect to server and select database.
  mysql_connect("$host", "$username", "$password")or die("cannot connect");
  mysql_select_db("$db_name")or die("cannot select DB");
  
  // Get values from form
  $month=mysql_real_escape_string($_POST['month']);
  $listner_name=mysql_real_escape_string($_POST['listner_name']);
  $rj_name=mysql_real_escape_string($_POST['rj_name']);
  $channel=mysql_real_escape_string($_POST['channel']);
  $year=mysql_real_escape_string($_POST['year']);
  $country=mysql_real_escape_string($_POST['country']);
  
  // Insert data into mysql
  
  $sql="INSERT INTO song_request (month, listner_name, rj_name, channel, year, country)VALUES('$month', '$listner_name', '$rj_name', '$channel', '$year', '$country')";
  $result=mysql_query($sql) or die ('error Updating database');
  
  // if successfully insert data into database, displays message "Successful".
  if($result){
  echo "Successful";
  echo "&lt;BR&gt;";
  echo "&lt;a href='index.html'&gt;Back to main page&lt;/a&gt;";
  }
  
  else {
  echo "ERROR";
  }
  
  // close connection
  mysql_close();
  ?&gt;
  </code></pre>
  
  <p>My HTML form code is</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html lang="en"&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
  
    &lt;title&gt;Radio Mantra Song Request&lt;/title&gt;
    &lt;link href="css/jquery.autocomplete.css" rel="stylesheet" type="text/css"&gt;
    &lt;link href="css/main.css" rel="stylesheet" type="text/css"&gt;
    &lt;script type="text/javascript" src="js/jquery-1.5.2.min.js"&gt;
  &lt;/script&gt;
    &lt;script type="text/javascript" src="js/jquery.autocomplete.pack.js"&gt;
  &lt;/script&gt;
    &lt;script type="text/javascript" src="js/script.js"&gt;
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;div class="container"&gt;
      &lt;form name="form" method="post" action="insert_ac.php"&gt;
        &lt;p&gt;&lt;label&gt;Location:&lt;/label&gt; &lt;input id="month" type="text" autocomplete="off"&gt;&lt;/p&gt;
  
        &lt;p&gt;&lt;label&gt;Listner Name:&lt;/label&gt; &lt;input id="listner_name" type="text" autocomplete=
        "off"&gt;&lt;/p&gt;
  
        &lt;p&gt;&lt;label&gt;RJ Name:&lt;/label&gt; &lt;input id="rj_name" type="text" autocomplete="off"&gt;&lt;/p&gt;
  
        &lt;p&gt;&lt;label&gt;Channel:&lt;/label&gt; &lt;input id="channel" type="text" autocomplete="off"&gt;&lt;/p&gt;
  
        &lt;p&gt;&lt;label&gt;Show Name:&lt;/label&gt; &lt;input id="year" type="text" autocomplete="off"&gt;&lt;/p&gt;
  
        &lt;p&gt;&lt;label&gt;Song:&lt;/label&gt; &lt;input id="country" type="text" autocomplete="off"&gt;&lt;/p&gt;
  
        &lt;h2&gt;Radio Mantra&lt;/h2&gt;
  
        &lt;table&gt;
          &lt;tr&gt;
            &lt;td align="center"&gt;&lt;input type="submit" name="submit" value="Submit"&gt;&lt;/td&gt;
          &lt;/tr&gt;
        &lt;/table&gt;
      &lt;/form&gt;
    &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>