PHP插入记录到MYSQL
时间:2009-04-22 来源:hkebao
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<style type="text/css">
<!--
input { font-size:9pt;}
A:link {text-decoration: underline; font-size:9pt;color:000059}
A:visited {text-decoration: underline; font-size:9pt;color:000059}
A:active {text-decoration: none; font-size:9pt}
A:hover {text-decoration:underline;color:red}
body,table {font-size: 9pt}
tr,td{font-size:9pt}
-->
</style>
<title>会员注册 - 添加记录演示</title>
</HEAD>
<body alink="#FF0000" link="#000099" vlink="#CC6600" topmargin="8" leftmargin="0" bgColor="#FFFFFF">
<br><br><center><font color=green size=3><b>注 册 会 员 表 单</b></font></center>
<br>
<form action="82.php" method="get" name="frmAdduser">
<table cellspacing=0 bordercolordark=#FFFFFF width="60%" bordercolorlight=#000000 border=1 align="center" cellpadding="2">
<tr bgcolor="#6b8ba8" style="color:FFFFFF">
<td width="100%" align="center" valign="bottom" height="19" colspan="2">请仔细填写以下内容</td>
</tr>
<tr>
<td width="30%" align="right" height="19">姓名:</td>
<td width="70%"><input type="text" name="userid" size="10" maxlength="18"></td>
</tr>
<tr>
<td width="30%" align="right" height="19">性别:</td>
<td width="70%"><input type="text" name="name" size="10" maxlength="18"></td>
</tr>
<tr>
<td width="100%" align="center" colspan="2"><input type="submit" value="马上注册"> <input type="reset" value="全部重写"></td>
</tr>
</table>
</form>
<?php
/*1. 连接MYSQL*/
$conn = mysql_connect("localhost:3306","root","321");
/*2. 选择DB*/
mysql_select_db("php",$conn);
/*3. 写SQL*/
$id=$_GET["userid"];
$name=$_GET["name"];
$SQL="Insert into test(id,name) values($id,'$name')";
print($SQL);
/*4. 执行SQL更新操作*/
$result=mysql_query($SQL,$conn) or die(mysql_error());
/*5. 关闭连接*/
mysql_close($conn);
?>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<style type="text/css">
<!--
input { font-size:9pt;}
A:link {text-decoration: underline; font-size:9pt;color:000059}
A:visited {text-decoration: underline; font-size:9pt;color:000059}
A:active {text-decoration: none; font-size:9pt}
A:hover {text-decoration:underline;color:red}
body,table {font-size: 9pt}
tr,td{font-size:9pt}
-->
</style>
<title>会员注册 - 添加记录演示</title>
</HEAD>
<body alink="#FF0000" link="#000099" vlink="#CC6600" topmargin="8" leftmargin="0" bgColor="#FFFFFF">
<br><br><center><font color=green size=3><b>注 册 会 员 表 单</b></font></center>
<br>
<form action="82.php" method="get" name="frmAdduser">
<table cellspacing=0 bordercolordark=#FFFFFF width="60%" bordercolorlight=#000000 border=1 align="center" cellpadding="2">
<tr bgcolor="#6b8ba8" style="color:FFFFFF">
<td width="100%" align="center" valign="bottom" height="19" colspan="2">请仔细填写以下内容</td>
</tr>
<tr>
<td width="30%" align="right" height="19">姓名:</td>
<td width="70%"><input type="text" name="userid" size="10" maxlength="18"></td>
</tr>
<tr>
<td width="30%" align="right" height="19">性别:</td>
<td width="70%"><input type="text" name="name" size="10" maxlength="18"></td>
</tr>
<tr>
<td width="100%" align="center" colspan="2"><input type="submit" value="马上注册"> <input type="reset" value="全部重写"></td>
</tr>
</table>
</form>
<?php
/*1. 连接MYSQL*/
$conn = mysql_connect("localhost:3306","root","321");
/*2. 选择DB*/
mysql_select_db("php",$conn);
/*3. 写SQL*/
$id=$_GET["userid"];
$name=$_GET["name"];
$SQL="Insert into test(id,name) values($id,'$name')";
print($SQL);
/*4. 执行SQL更新操作*/
$result=mysql_query($SQL,$conn) or die(mysql_error());
/*5. 关闭连接*/
mysql_close($conn);
?>
相关阅读 更多 +