这是我正在编写的代码(它是本教程的一部分http://www.homeandlearn.co.uk/php/php4p9.html)
这很好用
` 一个基本的 HTML 表单
<?PHP
if (isset($_POST['Submit1'])) {
$username=$_POST['username'];
if($username=="ken"){
print("you the man");
}
else {
print("you are not supposed to be here");
}
}
else{
$username="";
}
?>
</head>
<body>
<FORM NAME ="form1" METHOD ="post" ACTION = "basicForm.php">
username: <INPUT TYPE = "TEXT" VALUE ="<?PHP print $username;?>"NAME="username">
<INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Login">
</FORM>
</body>
</html>`
但这并不
<html>
<head>
<title>A BASIC HTML FORM</title>
<?PHP
if (isset($_POST['Submit1'])) {
$username=$_POST['username'];
$nickname=$_POST['nickname'];
if($username=='ken'and$nickname=='hawk'){
print("you the man");
}
else {
print("you are not supposed to be here");
}
}
else{
$username=""and$nickname="";
}
?>
</head>
<body>
<FORM NAME ="form1" METHOD ="post" ACTION = "testformken.php">
nickname: <input type="text" VALUE ="<?PHP print $nickname;?>" name="nickname" /><br />
username: <input type="text" VALUE ="<?PHP print $username;?>" name="username" />
<INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Login">
</FORM>
</body>
</html>
我收到此通知:未定义变量:C:\wamp\www\testformken.php 中的昵称在第 30 行调用堆栈#TimeMemoryFunctionLocation 10.1800367256{main}()..\testformken.php:0 " name="nickname" />
我搞砸了一些事情,如果我改变
nickname: <input type="text" VALUE ="<?PHP print $nickname;?>" name="nickname" /><br />
to
nickname: <input type="text" VALUE ="<?PHPprint$nickname;?>" name="nickname" /><br />
我没有得到未定义的变量,但如果我将值更改为,它也不会打印昵称
<?PHP print $username;?>
在此处输入代码我没有得到未定义的变量。