使用php的简单登录表单
我正在尝试写一个简单的登录表单。 但无论我输入什么密码,我总是被引导到同一个页面。 我是php新手,请原谅我的简单问题使用php的简单登录表单,php,html,login,Php,Html,Login,我正在尝试写一个简单的登录表单。 但无论我输入什么密码,我总是被引导到同一个页面。 我是php新手,请原谅我的简单问题 <?php if(isset($_POST['password'])) { if($_POST['password'] == 'admin') { header ( 'Location: home.html '); } else { echo "Wrong Pa
<?php
if(isset($_POST['password'])) {
if($_POST['password'] == 'admin') {
header ( 'Location: home.html ');
}
else {
echo "Wrong Password";
exit ;
}
}
?>
<html>
<form action="index.php" method ="POST">
Please Enter the Password:
</br>
<input type= "password" name= "password" />
<input type = "submit" value = "Go!" />
</form>
</html>
请输入密码:
尝试更改
metod ="POST"
致:
方法
,它的方法
enctype=“multipart/form data”
<?php
if(isset($_POST['submit']))
{
if($_POST['password'] == 'admin')
{
header ( 'Location: home.html ');
}
else
{
echo "Wrong Password";
exit ;
}
}
?>
<html>
<form action="index.php" method ="POST">
Please Enter the Password:
</br>
<input type= "password" name= "password" />
<input type = "submit" name="submit" value = "Go!" />
</form>
请输入密码:
泰尔,这是密码。在行动中使用#
if($\u POST['password']=='admin'){
标题('Location:home.html');
}
否则{
回显“密码错误”;
出口
}
}
?>
请输入密码:
试试这个
if(isset($_POST['submit'])) {
if($_POST['password'] == 'admin') {
header ('Location:process.php');
}
else {
echo "Wrong Password";
exit ;
}
}
?>
<form action="enclosedHTMLtag.php" method="post">
Please Enter the Password:
</br>
<input type="password" name="password" />
<input type="submit" value="Go!" name="submit" />
</form>
if(isset($\u POST['submit'])){
如果($_POST['password']=='admin'){
标题('Location:process.php');
}
否则{
回显“密码错误”;
出口
}
}
?>
请输入密码:
我在enclosedHTMLtag.php
编写了这段代码,我正在enclosedHTMLtag.php
提交这张表格,如果你想在任何文件中提交这张表格,请将这张表格更改为action=“enclosedHTMLtag.php”
更简单的是,如果您想在同一页提交表单,请使用此+1,用于鹰眼;)谢谢!没注意到!:)检查我的@user2727841答案…为什么“?>”在你代码的末尾?我想他只是忘了删除它。^^@Ashish是的,如果表单操作php代码在同一页面中,则应写为“表单操作=”“method=“post”“>。您的代码没有问题。如果您的编码文件名为index.php
,与您的操作
相同,那么它应该可以工作,就像我的测试一样。如有疑问,请使用action=“
而不是action=“index.php”
<?php
if(isset($_POST['password'])) {
if($_POST['password'] == 'admin') {
header ( 'Location: home.html ');
}
else {
echo "Wrong Password";
exit ;
}
}
?>
<html>
<form action="<?echo $PHP_SELF;?>" method ="POST">
Please Enter the Password:
</br>
<input type= "password" name= "password" />
<input type = "submit" value = "Go!" />
</form>
if($_POST['password'] == 'admin') {
header ( 'Location: home.html ');
}
else {
echo "Wrong Password";
exit ;
}
}
?>
<html>
<form action="#" method="post">
Please Enter the Password:
</br>
<input type= "password" name= "password" />
<input type = "submit" value = "Go!" name="submit" />
</form>
</html>
if(isset($_POST['submit'])) {
if($_POST['password'] == 'admin') {
header ('Location:process.php');
}
else {
echo "Wrong Password";
exit ;
}
}
?>
<form action="enclosedHTMLtag.php" method="post">
Please Enter the Password:
</br>
<input type="password" name="password" />
<input type="submit" value="Go!" name="submit" />
</form>