004 PHP MySQL Database Beginner Tutorial – PHP Checkbox Array – MySQL Insert Record part 1 – Hindi




Welcome Everyone, this video tutorial series is about PHP MySQL Tutorial in Hindi. This will be help for beginner who want to learn php mysql connectivity concepts. Various php mysql database…

Original source


12 responses to “004 PHP MySQL Database Beginner Tutorial – PHP Checkbox Array – MySQL Insert Record part 1 – Hindi”

  1. here is the code

    <html>
    <head>
    <title>
    php practiece
    </title>
    </head>
    <body>
    <form method="post">
    Enter your first name<input type="text" name="fname" ><br>
    Enter your last name<input type="text" name="lname"><br>

    Gender <input type="radio" name="g" value="male">
    Male
    <input type="radio" name="g" value="female">
    Female
    <br>

    Languages
    <input type="checkbox" name="l1"> English
    <input type="checkbox" name="l2"> Bangla
    <input type="checkbox" name="l3"> Hindi

    <br>

    <input type="submit" value="save">
    </form>

    </body>
    </html>

    <?php
    if($_POST["submit"]=="save")
    {
    $fname= $_POST["fname"];
    $lname= $_POST["lname"];
    $gender= $_POST["g"];
    $l1= $_POST["l1"];
    $l2= $_POST["l2"];
    $l3= $_POST["l3"];

    echo "<pre>";
    print_r($_POST);
    echo "</pre>";
    exit;

    mysql_connect("localhost","root","");
    mysql_select_db("test");

    $s="insert into contact(fname,lname,gender) values('".$fname."','".$lname."','".$gender."')";

    if(mysql_query($s))
    echo"Successful";

    else
    echo mysql_error();

    }

  2. Sir ye Error Araha ha Mane same ap jaisa code likha ha… Plz help me

    Notice: Undefined index: l3 in C:wampwwwyoutube-practiseinsertdata-checkbox.php on line 10
    Notice: Undefined index: l4 in C:wampwwwyoutube-practiseinsertdata-checkbox.php on line 11
    Line number 10: $l3= $_POST['l3'];
    Line number 11 $l4= $_POST['l4'];

    Full Code:

    <form action="" method="post">
    First Name: <input type="text" name="fname"><br>
    Last Name: <input type="text" name="lname"><br>
    Gender: <input type="radio" name="g" value="male">Male
    <input type="radio" name="g" value="female">Female <br>

    Languages <input type="checkbox" name="l1" value="1"> urdu
    <input type="checkbox" name="l2" value="1"> Sindhi
    <input type="checkbox" name="l3" value="1"> English
    <input type="checkbox" name="l4" value="1"> Balochi<br>
    <input type="submit" name="submit" value="sumbit">
    </form>

    <?php

    if(isset($_POST['submit']))
    {
    $fname= $_POST['fname'];
    $lname= $_POST['lname'];
    $gender= $_POST['g'];
    $l1= $_POST['l1'];
    $l2= $_POST['l2'];
    $l3= $_POST['l3'];
    $l4= $_POST['l4'];

    /*echo "<pre>";
    print_r($_POST);
    echo "</pre>"; exit;*/

    $con = mysqli_connect('localhost','root','') or die("Error in Connection");
    $database= mysqli_select_db($con, 'databaseconnection') or die("database connection error");

    if( $query= mysqli_query($con, "insert into biodata (fnme,lname,gender,urdu,sindhi,english,balochi) values('$fname','$lname','$gender','$l1','$l2',$l3,$l4) ") )

    {
    echo "Record Inserted";
    }
    else
    {
    echo mysqli_error($con);
    }

    }

    ?>

Leave a Reply