[英]Sign In won't Work
我已经创建了一个基本的签到形式:
<form action = "" type = "post">
<input type = "text" name = "txt_user" placeholder = "Username" required/>
<input type = "password" name = "txt_pass" placeholder = "Password" required/>
<input type = "submit" name = "btn_submit" value = " Sign In ">
并在我的HTML上面发布:
<?php
if(isset($_POST['btn_submit'])) {
$username = $_POST['txt_user'];
echo $username;
?>
要查看表单是否有效,它不会。 txt_user
不会显示应该是html的顶部,而是改变我的url:
localhost:8080/tryouts
对此:
http://localhost:8080/tryout/?si_username=asd&si_password=asdasd&si_submit=++Sign+In++
你能告诉我发生了什么吗? 我之前尝试过这种方法并且有效。 也许我放错了什么?
更新
包含该表单的页面名为signin.php
,它被放置在index.php
如下所示:
<body>
<?php include("signin.php"); ?>
</body>
这样做的目的是节省PHP代码的时间和空间,这样我就不会在页面之间更改登录表单,只需更改登录页面的主页面。 我不认为这会造成这种情况,但仍然......
您需要将form method
设置为POST
; form type
无效。 现在,它默认使用GET
。
<form action = "" method = "post">
<input type = "text" name = "txt_user" placeholder = "Username" required/>
<input type = "password" name = "txt_pass" placeholder = "Password" required/>
<input type = "submit" name = "btn_submit" value = " Sign In ">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.