Copy Code code as follows:
<title> Insert a new piece of data </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<body>
<form method= "Post" Name= "Form1" action= "insert.php" >
<table align= "center" >
<tr valign= "Baseline" >
<TD nowrap align= "right" > number:</td>
<td><input type= "text" name= "id" value= "size=" ></td>
</tr>
<tr valign= "Baseline" >
<TD nowrap align= "right" > Username:</td>
<td><input type= "text" name= "username" value= "" size= "></td>
</tr>
<tr valign= "Baseline" >
<TD nowrap align= "right" > Password:</td>
<td><input type= "text" name= "password" value= "" size= "></td>
</tr>
<tr valign= "Baseline" >
<TD colspan= "2" Nowrap><input name= "Submission" type= "submit" value= "submitted" >
<input type= "reset" name= "reset" value= "reset" ></td>
</tr>
</table>
</form>
</body>
Copy Code code as follows:
<?php
@mysql_connect ("localhost", "root", "1981427")//Select database before you need to connect to the database server
Or Die ("Database server Connection Failed");
@mysql_select_db ("test")//Select Database MyDB
Or Die ("database does not exist or not available");
$id = $_post[' id '];
$username = $_post[' username '];
$password = $_post[' password '];
$query = mysql_query ("INSERT into tablename1 values ($id, ' $username ', ' $password ')");
if ($query)
echo "Data insertion success";
Else
echo "Data insertion failed";
Mysql_close ();
?>