Insert data into mysql table in php using mysqli method

Create File first.php using form

        display: block;
    <form method="post" action="second.php" enctype="multipart/form-data">
<input type="text" name="user_name">
<input type="password" name="user_password">

Male <input type="radio" name="gender" value="male" checked>
Female <input type="radio" name="gender" value="female">

<input type="checkbox" name="car" value="Maruti"> Car 
<input type="checkbox" name="house" value="Narela"> House 
<input type="checkbox" name="bike" value="Bajaj"> Bike 

<input type="file" name="image[]" multiple>

<input type="submit" value="Click" name="click">

Create file second.php to insert data into table

this example show only two fields, you can add more field in php code to insert.


$link= mysqli_connect($host, $user, $password, $database);
    echo "Not Connected".mysqli_error($link);


$cmd="insert into user  set user_name='$user_name', user_password='$user_Password'";
if(mysqli_query($link, $cmd))
 echo "Success";   
    echo "User Already Exists";//mysqli_error($link);


Leave a Reply