Friday, January 3, 2014

Insert into Data Base Using PHP

Here i am going to tell you how to insert data into database and how can we connect a php page to the database 
the connection is made in php page by using the query in html page.

<h1>A small example page to insert some data in to the MySQL database using PHP</h1>
<form action="insert2.php" method="post">
Firstname: <input type="text" name="fname" /><br><br>
Lastname: <input type="text" name="lname" /><br><br>
<input type="submit" />

$con = mysql_connect("localhost","root","");
if (!$con)
  die('Could not connect: ' . mysql_error());

mysql_select_db("sun12k", $con);
$sql="INSERT INTO nametable (firstname, lastname)
if (!mysql_query($sql,$con))
  die('Error: ' . mysql_error());
echo "1 record added";

1 comment:

  1. My friend Suggest me this blog and I can say this is the best blog to get the basic knowledge.Thank you so much for this Selenium Training in Chennai


Related Posts Plugin for WordPress, Blogger...