• Tuesday , 19 September 2017

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

Code Canyon



https://youtu.be/78RUaIe4X0A How to Insert Data Into Database from a Web form | PHP – MySql Tutorial for Beginners. Learn to Insert data into Database using …

Original source

3d Ocean

Related Posts

29 Comments

  1. Hello Deutschland
    July 5, 2017 at 10:15

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

  2. Remix Studio
    July 5, 2017 at 10:15

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

    $name=$_post["name"];
    $address=$_post["address"];
    $phone=$_post["phone"];

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

    ?>

  3. Colin Nolan
    July 5, 2017 at 10:15

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

  4. Neville Koul
    July 5, 2017 at 10:15

    thank you . nice video

  5. Trimay Wear Plate Ltd
    July 5, 2017 at 10:15

    can I have the code?

  6. Rui Maria Vaz Pinto Rebelo de Andrade
    July 5, 2017 at 10:15

    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();
      }if(isset($_POST['submit'])){
     $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')";
     if(mysqli_query($con,$query))
     {
      echo"<h3>Data was inserted successfully</h3>";
     }}?>

  7. 98055 22098
    July 5, 2017 at 10:15

    not working

  8. Sirch
    July 5, 2017 at 10:15

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

  9. fah173
    July 5, 2017 at 10:15

    how can i contact you

  10. Info
    July 5, 2017 at 10:15

    sir background music kam rhka kry gy

  11. Evan Higgins
    July 5, 2017 at 10:15

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

  12. Yash Lakha
    July 5, 2017 at 10:15

    can I get the source code used in the video?

  13. Shaik Firasat Ali
    July 5, 2017 at 10:15

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

  14. nia arissa
    July 5, 2017 at 10:15

    where is the next?

  15. Md Mahmudul Hasan
    July 5, 2017 at 10:15

    Hello I Have An Error ……….Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:xampphtdocsselimconnect.php:33 Stack trace: #0 {main} thrown in C:xampphtdocsselimconnect.php on line 33

  16. crashvolt
    July 5, 2017 at 10:15

    brilliant, quick and simple. great clip

  17. Sougata Sarkar
    July 5, 2017 at 10:15

    i see only blank page after inserting data

  18. Rahul Raj Barnwal
    July 5, 2017 at 10:15

    getting this "syntax error, unexpected '$query' (T_VARIABLE)"
    in << $query = "insert into student (name,sname,roll,class) values ($name,$sname,$roll,$class)"; >>

  19. Ali Mohd mughal
    July 5, 2017 at 10:15

    finally something works great job bro

  20. John Michael Tan
    July 5, 2017 at 10:15

    can you check my codes please 🙂

    <html>
    <head><title>Student's Data</title></head>
    <body background="Image.jpg">
    <form action="connect.php" method="post">
    <marquee><h2>WELCOME…..!!!!!</h2></marquee>

    <center><table border="1" width="400" height="300">
    <tr>
    <td colspan="5" align="center" bgcolor="grey">Student's Information</td>
    </tr>
    <tr>
    <td align="right">Name:</td><td><input type="text" name="name"></td>
    </tr>
    <tr>
    <td align="right">Father's Name:</td><td><input type="text" name="name"></td>
    </tr>
    <tr>
    <td align="right">Roll No.:</td><td><input type="text" name="name"></td>
    </tr>
    <tr>
    <td align="right">Result:</td><td><input type="text" name="name"></td>
    </tr>
    <tr>
    <td colspan="5" align="center"><input type="submit" name="submit" value="submit"></td>
    </tr>
    </table></center>
    </form>
    </body>
    </html>

    <?php

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

    if(isset($_POST['submit'])){
    $name=$_POST['name'];
    $fname=$_POST['fname'];
    $roll=$_POST['roll'];
    $result=$_POST['result'];

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

    ?>

    theres a problem between the line

    Notice: Undefined index: fname in C:xampphtdocsstudentconnect.php on line 38

    Notice: Undefined index: roll in C:xampphtdocsstudentconnect.php on line 39

    Notice: Undefined index: result in C:xampphtdocsstudentconnect.php on line 40

  21. AjayK
    July 5, 2017 at 10:15

    Hey I have written exactly what u told in the video & its working also but the prob is that it is not getting save to my database what to do??? Please suggest…

  22. vinay chugh
    July 5, 2017 at 10:15

    if(mysql_query($query)
    closing bracket is not there .. how it is running ?
    it should be written like this ..if(mysql_query($query))

  23. ambusher 1234
    July 5, 2017 at 10:15

    thankyou so much, very informative and precise. Please upload further videos to do with this topic, retrieve data from database, altering data within the database using php.
    many thanks

  24. mohsin sofi
    July 5, 2017 at 10:15

    sir i want to insert, update , delete and search in one video please help me in that,,,, thanx

  25. MINU THOMAS
    July 5, 2017 at 10:15

    u…r…best…

  26. Nick Jenkins
    July 5, 2017 at 10:15

    Is there any way you could put your code into the description for easy copying and pasting? Thanks!

  27. Marjan Stojanovski
    July 5, 2017 at 10:15

    there is no need for the background music,

  28. Zen Tweak
    July 5, 2017 at 10:15

    Parse error syntax error, unexpected '{' in C:xampphtdocsstudentcontacts.php
    Same as Antonina Panayiotou. Verified code

  29. Antonina Panayiotou
    July 5, 2017 at 10:15

    Hi i have an error
    Parse error: syntax error, unexpected '{' in C:xampphtdocseasylearnUTUBEconnect.php on line "{ echo "<h3>Student's data is inserted successfully</h3>"; }"
    but the code is exactly as yours !! 🙁
    what to do???

Leave A Comment

You must be logged in to post a comment.