<html>
<head>
<title>Register</title>
<head>
<body>
<h3>Register Page</h3>
<a href="index.php">Click here to go back</a></br>
<form action="register.php" method="post">
Enter Username: <input type="text" name="username" required="required"/></br>
Enter Password: <input type="password" name="password" required="required"/></br>
<input type="submit" value="Register"/>
</form>
</body>
</html>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
echo "Username is :" . $username . "<br>";
echo "Password is :" . $password;
}
?>
当我使用任意随机用户名和密码执行页面时,它不会在我写的文本框中显示文本和密码。
答案 0 :(得分:0)
用以下内容替换您的PHP代码:
<?php
if (isset($_POST['username']) && isset($_POST['password'])){
$username = $_POST['username'];
$password = $_POST['password'];
echo "Username is :" . $username . "<br>";
echo "Password is :" . $password;
}
?>