[英]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.