Home / Tutorials / PHP Tutorials / Insert Data into MySql Database lecture 2 of 3 in Urdu

Insert Data into MySql Database lecture 2 of 3 in Urdu

Lecture 2 PHP + MySql Database

After creating HTML form and Database  we create a file of insert.php name for insert data in the database the code.

 

Code:

<?php

$conn=mysql_connect(“localhost”, “root”, “”);
//Chesk connection with server
if(!$conn)
{
die (“Not Connected to Server”);

}
// Chesk connection with Datbase
if (!mysql_select_db(“shahzad”,$conn ))
{
die (“Not Connected to Database”);

}
$sname=$_POST[‘sname’];
$fname=$_POST[‘fname’];
$email=$_POST[’email’];
$dob=$_POST[‘dob’];
$gender=$_POST[‘gender’];

$sql=”INSERT INTO bscs (sname, fname, email, dob, gender)
VALUES (‘$sname’,’$fname’,’$email’,’$dob’,’$gender’ )”;
if(mysql_query($sql))
{
echo “cong… your data is inserted”;

}
else
echo “Data not inserted”;

?>

 

About Shahzad Younas

Shahzad Younas in a Beginner of Web Developing and Web Designing and a Blogger Master

Check Also

Android App Development Tutorials in Urdu / Hindi part 1 introduction

Welcome In Android Complete App Development 2016 Training In Urdu and Hindi Android is open source and …

Leave a Reply

Your email address will not be published. Required fields are marked *