[英]php html Why isn't my form showing on the webpage?
I simply cannot understand how and why I am not seeing a form, when opening my site??? 打开网站时,我根本无法理解为什么以及为什么看不到表格??? I wan a form consisting of bot username, password and a subit box to appear, though I don't see the solution here...
我要显示一个由机器人用户名,密码和子对话框组成的表单,尽管我在这里看不到解决方案...
A solution and explaining would be much appreciated. 解决方案和解释将不胜感激。
<?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>
thanks in advance! 提前致谢!
You didn't print your form from PHP or mistakenly wrapped your form in PHP. 您没有从PHP打印表单,也没有错误地将表单包装在PHP中。 It was wrapped around the
<?php
tag in the variable $form
but no print to screen. 它被包裹在变量
$form
的<?php
标记周围,但没有打印到屏幕上。
This is how it should look like below with errors working correctly ;-) 这是下面的样子,错误可以正常工作;-)
<?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>
您也没有回显您的变量
Try changing your php at the bottom to the following. 尝试将底部的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;
}
<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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.