Multi Check box value insert in database

Saturday, October 3, 2015

please check my code i am getting error. I don’t know why, where is problem.here is my code.

<?php 
$mysqli=new mysqli("localhost","root","","test") or die("Connection error");
if(isset($_POST['login']))
 {
$buy=$_POST['buy'];
$sell=$_POST['sell'];
$rent=$_POST['rent'];

$data=$mysqli->query("insert into user_name(rent,buy,sell)values('$rent','$buy','$sell')"); 
if($data)
echo "done";
else
echo "fails";
}

here is html

<form action="#" method="post" enctype="multipart/form-data">


Choose Option
Buy Sell Rent
 
            <input type="submit" value="Login" name="login" />
         </form>

there are three column in database and i want to insert each checked value in database if check insert 1 otherwise 0.


0 comments:

Post a Comment