- 论坛徽章:
- 0
|
本帖最后由 jgcjsw 于 2011-10-18 12:31 编辑
这个问题搞了我几天都没有搞清楚,如果不加红色部分的内容,newname中不管输入或不输入任何内容,直接点击表单中的Add user按钮,程序
都会执行InsertUser和header函数。这是为什么啊?查了一下$_POST['newname']的直是空的啊
<?php
include_once 'conn.class.php';
include_once 'funs.inc.php';
$con=new conn;
$mysqli=$con->conndb();
if (isset($_POST['Msub']))
{
if (!isset($_POST['newname']) || strlen($_POST['newname'])==0)
{
echo "UserName can not be null.<br>";
var_dump(isset($_POST['newname']));
return ;
}else{
InsertUser("{$_POST['newname']}", "{$_POST['newpass']}",$mysqli);
header("location:get_data.php");
}
}
?>
////////////以下是表单内容
<html>
<head>
<title>User Managerment</title>
<link rel="stylesheet" type="text/css" href="userManager.css">
</head>
<body>
<form action="userManager.php" method="post">
UserName:<input type="text" name="newname"><p>
UserPass:<input type="password" name="newpass"><p>
<hr>
<p>
<input type="submit" name="Msub" value="Add user">
<input type="reset" name="res" value="Reset">
</form>
</body>
</html> |
|