How to Insert Data Into Database from a Form | PHP – MySql Tutorial for Beginners

KuberRuimte , South Africa – A terrible experience, steer clear – Horrible technical support, takes weeks to get a response. Rued representatives. Several billing errors. You are better off taking your business elsewhere.
How to Insert Data Into Database from a Web form | PHP – MySql Tutorial for Beginners. Learn to Insert data into Database using Xampp/Wamp.

Thanks For Watching Our Video. Please Like And Suscribe Our Channel For more. 🙂


  • Hello Deutschland
    Posted at 05:55h, 30 November

    i have error in { echo"<h3> Student's data is inserted successfully </h3> } can you explian it Please Please

  • Shaik Firasat Ali
    Posted at 12:50h, 17 March

    Good vedio it really helped me in my project.
    i got inspired.😊😊😊

  • Yash Lakha
    Posted at 14:56h, 20 March

    can I get the source code used in the video?

  • Evan Higgins
    Posted at 18:11h, 31 March

    Nothing happens when I press submit. No new information is inserted into my database 🙁

  • fah173
    Posted at 03:31h, 17 April

    how can i contact you

  • Sirch
    Posted at 05:51h, 20 April

    Thank your for the tutorial. Only ran into one problem but saw that you answered it in someones comment. Thanks.

  • 98055 22098
    Posted at 21:46h, 03 May

    not working

  • Rui Maria Vaz Pinto Rebelo de Andrade
    Posted at 12:09h, 07 May

    Hello. What im doing wrong? when I submit it returns to same page and data was not inserted in phpmyadmin.

    <?php$con = mysqli_connect("localhost","root","","alenbaga");if (mysqli_connect_errno())
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
     $num = $_POST['num_trab'];
     $nome = $_POST['nome'];
     $empresa = $_POST['empresa'];
     $sexo = $_POST['sexo'];
     $ano = $_POST['ano'];
     $query = "insert into employee (num_trab,nome,empresa,sexo,ano) values('$num','$nome','$empresa','$sexo','$ano')";
      echo"<h3>Data was inserted successfully</h3>";

  • Trimay Wear Plate Ltd
    Posted at 20:50h, 24 May

    can I have the code?

  • Neville Koul
    Posted at 19:56h, 03 June

    thank you . nice video

  • Colin Nolan
    Posted at 00:00h, 19 June

    Great video and it helped me so much. You made it look so easy!!Kindest Regards

  • Remix Studio
    Posted at 11:27h, 29 June

    Can you tell me whats wrong with this code.
    <form name="form1" method="post" action="b.php">
    <table border=1>
    <td colspan="2">Submit to Datatbase</td>
    <td>Name:</td><td><input type="text" size="50" name="name" maxlength="50"></td>
    <td>Address:</td><td><input type="text" size="50" name="address" maxlength="50"></td>
    <td>Phone:</td><td><input type="text" size="50" name="phone" maxlength="50"></td>
    <td colspan="2"><button type=""submit">Submit</button></td>
    $db= mysql_connect("localhost","root","");
    exit("Error-could not connect to MySQL");
    exit("Error-could not select the database.");


    $qry="insert into tbl_student(name,address,phone) values('$name','$address','$phone')";
    if(mysql_query ($qry))
    echo"successfully inserted";


  • rhea mykah raterta
    Posted at 15:47h, 07 July

    Hi! can you please check my code. I have an error.
    Notice: Undefined index: fname in C:xampphtdocsconnect.php on line 42
    Notice: Undefined index: roll in C:xampphtdocsconnect.php on line 43
    Notice: Undefined index: result in C:xampphtdocsconnect.php on line 44

    <head><title>Medical Data</title></head>
    <body background="image.jpg">
    <form action="connect.php" method="post">
    <center><table border="1" width="400" height="300">
    <td colspan="5" align="center" bgcolor="white">Performance Appraisal</td>
    <td align="right" >Name:</td><td><input type="text" name="name"></td>
    <td align="right">Father's name:</td><td><input type="text" name="name">
    <td align="right">Roll No.:</td><td><input type="text" name="name">
    <td align="right">Result:</td><td><input type="text" name="name">
    <td colspan="5" align="center"><input type="submit" name="submit" value="submit"></td>



    mysql_connect("localhost","root","") or die("not connected");
    mysql_select_db("student") or die("no db found");


    $query = "insert into data(name,fname,roll,result)values('$name','$fname','$roll','$result')";
    echo"<h3>Employee's data is inserted successfully</h3>";

    Thank you 🙂

    Posted at 02:37h, 13 July

    this is a great job man… keep it up… tks.

    Posted at 03:15h, 24 August

    Can you send me php source???
    Please send me.

  • abirame selvendran
    Posted at 02:04h, 27 August

    i have error *"if(isset($_POST['save'])
    { " here "{" this one is unexpect * can you explian it please

  • neoramyeon
    Posted at 04:16h, 02 September

    where to save this file??

  • Timi Odeyemi
    Posted at 20:27h, 05 October

    how can i make a link to automatically download using xampp?

  • Temyong Tem
    Posted at 12:38h, 08 October

    thanks a lot bro for this tutorial ….and plss can you upload other tutorial for view record, update, delete fucntion aslo search record plllss. i need it to my final project

    Posted at 06:33h, 11 October

    i have an error
    syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in line if(isset……….)

  • Charles Baulot
    Posted at 06:29h, 19 October

    Thanks very much !

  • SS Tech & Creations
    Posted at 19:13h, 27 October

    How to create mysql database, table and insert da…:

  • Teddy Ngeene
    Posted at 11:08h, 31 October

    very helpful

  • Prem ICFA
    Posted at 08:42h, 07 November

    Showing error Parse error: syntax error, unexpected 'echo' (T_ECHO) in {
    echo "<h2> Student's data is inserted successfully </h2>"

  • md najim alam
    Posted at 22:51h, 07 November

    great bro…….

  • Patrick Day
    Posted at 08:06h, 17 November

    these tutorials suck i don't want to read would rather have a narrated tutorial

  • Tshehla Thabang
    Posted at 02:24h, 18 November

    Most of the stuff you did was unnecessary.

  • Keith Au
    Posted at 14:30h, 01 December

    Yes。Thanks a lot Duke。for posing it at all。

  • Mohammad Hamdan
    Posted at 11:12h, 10 December

    thank You

  • Ξxodus
    Posted at 19:46h, 13 December

    im having a hell of a time trying to get anything to work

  • Y T reddy
    Posted at 16:17h, 25 December

    i have error Parse error: syntax error, unexpected end of file in C:xampphtdocsconnection.php on line 44
    can you explain please

  • Manoj Mahajan
    Posted at 07:43h, 09 February

    i have error in

    Fatal error: Uncaught Error: Call to undefined function mysql_query() in C:xampphtdocsstudentconnect.php:48 Stack trace: #0 {main} thrown in C:xampphtdocsstudentconnect.php on line 48

    <head><title>student data</title></head>
    <form action="connect.php" method="POST">

    <table border="1">
    <tr><td colspan="2">Student Informations</td></tr>
    <td>Name:</td><td><input tpe="text" name="name"></td>
    <td>Father Name</td><td><input tpe="text" name="fname"></td>
    <td>Roll No</td><td><input tpe="text" name="roll"></td>
    <td>Result</td><td><input tpe="text" name="result"></td>
    <td colspan="2"><input type="submit" name="submit" value="submit"></td>


    $servername = "localhost";
    $username = "root";
    $password = "";

    $mydb = new mysqli($servername, $username, $password);

    $name = $_POST['name'];
    $fname = $_POST['fname'];
    $roll = $_POST['roll'];
    $result = $_POST['result'];

    $query="Insert into data (name,fname,roll,result) value('$name','$fname','$roll','$result')";
    echo "<h3>Student's data is inserted successfully</h3>";



    what is the mistake please please

  • Yamraj p
    Posted at 21:57h, 10 March

    Not able to insert data in database , plz chk my query – $query = "INSERT INTO login_page(username,password) VALUES ('$username','$password')";

  • Ranjeet Deshmukh
    Posted at 04:50h, 27 March

    can u please give me the link of the last video. how to create database & making connection

    Posted at 19:35h, 31 March

    GREAT….👌👌👌plz put video about on retrieving data from database

  • getenet dires
    Posted at 07:41h, 08 May

    when i search to localhost:80/ it say can,t reached what is wrong

  • David Hernandez
    Posted at 22:50h, 10 May

    It didn't completely fix my problem I had but out of all my searches, this did really point me in the right direction. Thanks!

  • Humayun Nasir
    Posted at 07:31h, 07 July

    Great thanks alot

  • Arvinzeres Ampogi
    Posted at 08:09h, 01 August

    whats that little box thing after the code $_POST

  • S KF
    Posted at 13:43h, 09 August

    Great jop bro thanks.

  • jess jesse
    Posted at 23:20h, 24 August

    1: php youtube account login tricks ! Txt editing = mankind 666 ! Wrong used for own profit ! It demonicall alter -ego disorders !

  • jess jesse
    Posted at 23:21h, 24 August

    2: the 666 mankind & his keyboard txt editing file save storage ! Wrong dude !

  • Firoz Mahmud
    Posted at 13:18h, 02 September

    where is the problem?


    <body background="image.jpg">
    <marquee><h1 style=color:red >Welcome To Registratin Form</h1></marquee>
    <font face="Arial" color="black" size="5px"</font>

    <form "action=connect.php", method="post">
    Name <input type="text" name="Name">
    <input type="radio" name="gender" value="male">Male
    <input type="radio" name="gender" value="female">Female
    <option> Birth Date </option>
    <b>User Name</b> <input type="text"></input>
    <b>Password</b> <input type=password></input>
    <input type="checkbox">SSC
    <input type="checkbox">HSC
    <input type="checkbox">BSC
    <input type="checkbox">MSC
    <input type="submit" value="Register" name="Submit"><br><br>
    <input type="reset" value="Reset" name="clear"


    mysql_connect("localhost", "root") or die("Not Connected");
    mysql_select_db("Registration From") or die("No db Found");


    $name= $_POST['name'];
    $male= $_POST['male'];
    $female= $_POST['female'];
    $date= $_POST['date'];
    $user_name= $_POST['user name'];
    $password= $_POST['password'];
    $ssc= $_POST['ssc'];
    $hsc= $_POST['hsc'];
    $bsc= $_POST['bsc'];
    $msc= $_POST['msc'];

    $query = "inser into data(name,male,female,date,user_name,password,ssc,hsc,bsc,msc) value('$name','$male','$female',

    echo "data inserted successfull";



  • MOJO 24/7
    Posted at 07:15h, 30 October

    thank u its working good .do more tutorials in crurd applications.

  • Tan Mari
    Posted at 07:45h, 03 November

    Thnks a lot. Background music kept me awake and focused

  • sagar TM
    Posted at 19:17h, 14 November

    Upload next delete update videos