PHP在网页表单上提交内容到mysql数据库,报错,能提交,但是数据库更新不出来
<?include"conn.php";?><?print_r($_POST);?><?if($_POST[action]=="save"){die();$Name=$_...
<?
include "conn.php";
?>
<?
print_r($_POST);
?>
<?
if($_POST[action]=="save")
{
die();
$Name =$_POST[Name];
$UserName =$_POST[UserName];
$Password=$_POST[PassWord];
if($Name=='')
{
echo"<script> alert('请输入你的大名');</script>";
echo"<script language='javascript'>parent.window.history.go(-1);</script>";
}
else{
$sqr="insert into set Name='$Name' UserName=$UserName Password=$Password";
mysql_query($sql);
echo "<script> alert('添加成功!');</script>";}
}
die();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<form action="?" method="post" id="form1" name="form1">
<table width="278" border="1" align="center">
<tr>
<td><span class="STYLE2">姓名:</span></td>
<td width="245"><input name="Name" type="text" id="name" /></td>
</tr>
<tr>
<td><span class="STYLE2">用户名:</span></td>
<td><input name="UserName" type="text" id="UserName" /></td>
</tr>
<tr>
<td>密码:</td>
<td><input name="Password" type="password" id="Password" /></td>
</tr>
<tr>
<td><input name="save" type="hidden" id="save" /></td>
<td><input type="submit" name="submit" value="提交" />
<input type="reset" name="Submit2" value="重置" /></td>
</tr>
</table>
<label></label>
</form>
</body>
</html> 展开
include "conn.php";
?>
<?
print_r($_POST);
?>
<?
if($_POST[action]=="save")
{
die();
$Name =$_POST[Name];
$UserName =$_POST[UserName];
$Password=$_POST[PassWord];
if($Name=='')
{
echo"<script> alert('请输入你的大名');</script>";
echo"<script language='javascript'>parent.window.history.go(-1);</script>";
}
else{
$sqr="insert into set Name='$Name' UserName=$UserName Password=$Password";
mysql_query($sql);
echo "<script> alert('添加成功!');</script>";}
}
die();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<form action="?" method="post" id="form1" name="form1">
<table width="278" border="1" align="center">
<tr>
<td><span class="STYLE2">姓名:</span></td>
<td width="245"><input name="Name" type="text" id="name" /></td>
</tr>
<tr>
<td><span class="STYLE2">用户名:</span></td>
<td><input name="UserName" type="text" id="UserName" /></td>
</tr>
<tr>
<td>密码:</td>
<td><input name="Password" type="password" id="Password" /></td>
</tr>
<tr>
<td><input name="save" type="hidden" id="save" /></td>
<td><input type="submit" name="submit" value="提交" />
<input type="reset" name="Submit2" value="重置" /></td>
</tr>
</table>
<label></label>
</form>
</body>
</html> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询