-1

How to use html form and Php script in a same page so that i can use drop down menu to select with in my option and hence submit it to the mysql data base. here is the code and http://www.mutebag.com/table.php#openmodal is the link of the website i want to implement.The following code i am using please correct me

PHP :

$val=$_POST['company'];
$result=mysqli_query($con,"Select * from product_info where product_name= 'Beats' "); 

HTML :

<form action="<?php echo $_SERVER['PHP_SELF']; ?> " method="POST">              
   <select  id="company" name="company">
      <option value="Beats">Beats</option>
      <option value="Bose">Bose</option>
      <option value="Skull candy">Skull Candy</option>
      <option value="Sennehiser">Sennheiser</option>
   </select>
   <input type="submit" value="submit" id="submit"/> 
</form>
Roy M J
  • 6,926
  • 7
  • 51
  • 78
user2926947
  • 47
  • 1
  • 7
  • 1
    You are susceptible to sql injection. Please read : http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php – Roy M J Oct 28 '13 at 06:35

1 Answers1

1
<?php

if(isset($_POST))
{
$val=$_POST['company']; 
echo $val;// To make sure value is posted

$result=mysqli_query("Select * from product_info where product_name= '.$val.' "); 

}
?>
Arun CH
  • 101
  • 1
  • 12