在打开我的网站时,我根本无法理解为什么我没有看到表格?我想要一个由机器人用户名,密码和子框出现的表格,虽然我在这里看不到解决方案......
非常感谢解决方案和解释。
<?php
error_reporting(E_ALL ^ E_NOTICE);
session_start();
?>
<!DOCTYPE html>
<!--
-->
<html>
<head>
<meta charset="UTF-8">
<title>World Talk Login</title>
</head>
<body>
<?php
$form = "<form action='./login.php' method='post'>
<table>
<tr>
<td>Username:</td>
<td><input type='text' name='user'/></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='password'/></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='loginbtn' value='Login'/></td>
</tr>
</table>
</form>";
if ($_POST['loginbtn']){
$user = $_POST ['user'];
$password = $_POST['password'];
if ($user) {
if ($password){
echo "$user - $password <hr /> $form";
}
else
echo "You must enter your password. $form";
}
else
echo "You must enter your username. $form";
}
?>
</body>
</html>
提前感谢!
答案 0 :(得分:0)
您没有从PHP打印表单或错误地将表单包装在PHP中。它包含在变量<?php
中的$form
标记周围,但没有打印到屏幕。
如果错误正常工作,它应该如下所示;-)
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
?>
<!DOCTYPE html>
<!--
-->
<html>
<head>
<meta charset="UTF-8">
<title>World Talk Login</title>
</head>
<body>
<form action='./login.php' method='post'>
<table>
<tr>
<td>Username:</td>
<td><input type='text' name='user'/></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='password'/></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='loginbtn' value='Login'/></td>
</tr>
</table>
</form>
<?php
if ($_POST['loginbtn']){
$user = $_POST ['user'];
$password = $_POST['password'];
if ($user) {
if ($password){
echo "$user - $password <hr /> $form";
}
else
echo "You must enter your password. $form";
}
else
echo "You must enter your username. $form";
}
?>
</body>
</html>
答案 1 :(得分:0)
你也没有回应你的变量
答案 2 :(得分:0)
尝试将底部的php更改为以下内容。
if ($_POST['loginbtn']){
$user = $_POST ['user'];
$password = $_POST['password'];
if($user != "" && $password != "") {
echo "$user - $password <hr /> $form";
}
if($user == "") {
$error .= "You must enter your username.</br>";
}
if($password == "") {
$error .= "You must enter your password.";
}
if($error != "") {
echo $error.$form;
}
} else {
echo $form;
}
答案 3 :(得分:0)
<html>
<head>
<meta charset="UTF-8">
<title>World Talk Login</title>
</head>
<body>
<?php
$form = "<form action='./login.php' method='post'>
<table>
<tr>
<td>Username:</td>
<td><input type='text' name='user'/></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='password'/></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='loginbtn' value='Login'/></td>
</tr>
</table>
</form>";
echo $form;
if (!isset($_POST['loginbtn'])){
$user = (!isset($_POST['user']));
$password = (!isset($_POST['password']));
}
else{
}
?>
</body>
</html>