新手问题。以下代码不会打印任何内容。我不知道为什么请帮助我努力学习。
<HTML>
<head />
<body>
<form action="test.php" method=POST>
username: <input type="text" name="user"><br/>
password: <input type="password" name="pass"><br />
<input type="submit" value="go"><p>
</form
<?php
$user = $_POST['user'];
$pass= $_POST['pass'];
if(($user=="Rascal999")&&($pass=="poo"))echo "Access Granted";
else echo "Access Denied";
?>
</body>
</HTML>
感谢。
答案 0 :(得分:5)
您错过了结束标记:
更改
<form action="test.php" method=POST>
username: <input type="text" name="user"><br/>
password: <input type="password" name="pass"><br />
<input type="submit" value="go"><p>
</form
到
<form action="test.php" method=POST>
username: <input type="text" name="user"><br/>
password: <input type="password" name="pass"><br />
<input type="submit" value="go"><p>
</form>
答案 1 :(得分:0)
关注Phil Cross的Build和test.php
<?php
if(isset($_POST) && !empty($_POST)){
$user = $_POST['user'];
$pass= $_POST['pass'];
if( $user=="Rascal999" && $pass=="poo" ):
echo "Access Granted";
else:
echo "Access Denied";
endif;
}
?>
如果此页面是test.php,请在表单标记中删除操作并将上述代码粘贴到页面的开头