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
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
29 responses to “How to Insert Data Into Database from a Form | PHP – MySql Tutorial for Beginners”
i have error in { echo"<h3> Student's data is inserted successfully </h3> } can you explian it Please Please
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";
?>
Great video and it helped me so much. You made it look so easy!!Kindest Regards
thank you . nice video
can I have the code?
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>";
}}?>
not working
Thank your for the tutorial. Only ran into one problem but saw that you answered it in someones comment. Thanks.
how can i contact you
sir background music kam rhka kry gy
Nothing happens when I press submit. No new information is inserted into my database 🙁
can I get the source code used in the video?
Good vedio it really helped me in my project.
i got inspired.😊😊😊
where is the next?
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
brilliant, quick and simple. great clip
i see only blank page after inserting data
getting this "syntax error, unexpected '$query' (T_VARIABLE)"
in << $query = "insert into student (name,sname,roll,class) values ($name,$sname,$roll,$class)"; >>
finally something works great job bro
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
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…
if(mysql_query($query)
closing bracket is not there .. how it is running ?
it should be written like this ..if(mysql_query($query))
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
sir i want to insert, update , delete and search in one video please help me in that,,,, thanx
u…r…best…
Is there any way you could put your code into the description for easy copying and pasting? Thanks!
there is no need for the background music,
Parse error syntax error, unexpected '{' in C:xampphtdocsstudentcontacts.php
Same as Antonina Panayiotou. Verified code
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???