Friday, January 10, 2014

Registration Form: Inserting Data in PHP Database

 How To Insert New Data In Data Base In PHP

Sample Code
<html>
<head>
<title>Registration form</title>
</head>
<body>
<?php
$con=mysql_connect("localhost","root","");
$mysql_select_db("kiu");
$result=mysql_query("select * from student");
while($row=mysql_fetch-array($result))
if(mysql_connect_errno())
{
echo:"Failed tro connect to database".mysql_connect_error();
}
else
{
$sql:"INSERT INTO student values('$Reg_no','$Name','$F.name', '$password','$D_o_B','$Email')";

$query = mysql_query($sql);
if($query)
     echo $name . " has been added successfully";
else
echo "There was an error while inserting user to the database.";
}


</table>
</body>


</html>

0 comments:

Post a Comment