简体   繁体   English

登录将无法正常工作

[英]Sign In won't Work

I have created a basic sign in form: 我已经创建了一个基本的签到形式:

<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  ">

and posted this above my html: 并在我的HTML上面发布:

<?php
   if(isset($_POST['btn_submit'])) {
   $username = $_POST['txt_user'];
   echo $username;
?>

to see if the form works, it doesn't. 要查看表单是否有效,它不会。 The txt_user won't display up top the html as it should be but instead change my url from this: txt_user不会显示应该是html的顶部,而是改变我的url:
localhost:8080/tryouts

to this: 对此:
http://localhost:8080/tryout/?si_username=asd&si_password=asdasd&si_submit=++Sign+In++



can you tell me what's going on? 你能告诉我发生了什么吗? I tried this method before and it works. 我之前尝试过这种方法并且有效。 Maybe I misplaced something? 也许我放错了什么?

Update 更新
The page containing the form is called signin.php where it's been placed inside index.php like this: 包含该表单的页面名为signin.php ,它被放置在index.php如下所示:

<body>
<?php include("signin.php"); ?>

</body>

purpose of this is to save time and space for the php codes so that I won't be bother changing the sign in form from page to page, instead just changed the signin page main php page. 这样做的目的是节省PHP代码的时间和空间,这样我就不会在页面之间更改登录表单,只需更改登录页面的主页面。 I don't think it's causing this but still... 我不认为这会造成这种情况,但仍然......

You need to set your form method to POST ; 您需要将form method设置为POST ; form type is invalid. form type无效。 Right now, it's defaulting to using GET . 现在,它默认使用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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM