Not able to insert data in the database from a form in php
<p>I am not able to insert data into my data, i dont know what the problem is. Here is the code:</p>

<p><pre><code></p>

<p>

<p>mysql_select_db("mitestore", $con); */
if ((isset($_POST['product_name'])) &amp;&amp; (strlen(trim($_POST['product_name'])) > 0)) {
    $product_name = stripslashes(strip_tags($_POST['product_name']));
    $sql="INSERT INTO sell (product_name) VALUE ('$_POST[product_name]')";
} else {$product_name = 'Please enter the product name.';}
if ((isset($_POST[''])) &amp;&amp; (strlen(trim($_POST['how_old'])) > 0)) {
    $how_old = stripslashes(strip_tags($_POST['how_old']));
    $sql="INSERT INTO sell (how_old) VALUE ('$_POST[how_old]')";
} else {$how_old = 'Please enter how old your product is';}
if ((isset($_POST['which_block'])) &amp;&amp; (strlen(trim($_POST['which_block'])) > 0)) {
    $which_block = stripslashes(strip_tags($_POST['which_block']));
    $sql="INSERT INTO sell (which_block) VALUE ('$_POST[which_block]')";
} else {$which_block = 'Please enter which block are you from';}
if ((isset($_POST['room_no'])) &amp;&amp; (strlen(trim($_POST['room_no'])) > 0)) {
    $room_no = stripslashes(strip_tags($_POST['room_no']));
    $sql="INSERT INTO sell (room_no) VALUE ('$_POST[room_no]')";
} else {$room_no = 'Please enter the room no:';}
if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "Success!";</p>

<p>mysql_close($con)
?></p>

<p></pre></code></p>

<p>Initially i had this code and it worked for me.
<pre><code></p>

<p>mysql_select_db("database", $con);
$sql="INSERT INTO sell ( product_name, how_old , selling_price, negotiable, which_block, room_no)
VALUES
('$_POST[product_name]','$_POST[how_old]','$_POST[selling_price]','$_POST[negotiable]','$_POST[which_block]','$_POST[room_no]')";</p>

<p>if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "Your product is added.";
mysql_close($con)
?></p>

<p></pre></code></p>

<p>But i don't know how to validate each field individually. </p>
