为什么我的代码不提交密码,而是提交“;登录”;


Why does my code not submit password and instead submits "login"

使用Post时,我不会从表单中收到密码,但会从按钮中收到消息。

数组([用户名]=>000001[登录_btn]=>登录)

下面是代码。

<form action="checklogin.php" method="post">
    <div class="wrap"> <!--make a container that will have all our elements and will be the main stucture of you pages-->
        <div class="logo"></div><!--The logo container-->
        <div class="header_text">Room Booking</div><!--The main header of the fomr-->
        <div class="logins_details_container"><!--The top container-->
            <table class="fields_container"> <!--A simple 2x2 table for the form. We choose to use table as for this simple kind of stuff helps us to be everything well stuctured and putting less attributes at the css-->
                <tr>
                    <td><span>Username</span></td>
                    <td><input class="field" id="Username" name="Username" value="" placeholder="" type="text" /></td>
                </tr>
                <tr>
                    <td><span>Password</span></td>
                    <td><input class="field" id="Password" name="Password" value="" placeholder="" type="text" /></td>
                </tr>
            </table>
            <div class="remeber_me_container"><!--A container for the Remember me text and the checkbox-->
                <div class="remember_me">Remember Me?</div>
                <input  id="remeber_me" name="" value="" type="checkbox" />
            </div>
            <div class="login_btn"><!-- The login button-->
                <input name="login_btn" value="Login" type="submit" />
            </div> 
        </div>
<form/><!-- End of the logins_details_container -->

尝试更改

<input name="login_btn" value="Login" type="button" />

<input name="login_btn" value="Login" type="submit" />

我不确定这是否会阻止密码发送到您的PHP脚本,但您上面的HTML页面缺少一个closing-div。

       <form action="checklogin.php" method="post">
             <div class="wrap">
                  <form/>

(我已经删除了所有其他匹配的行&以上3行仍然存在。)

你需要使用来关闭你的表单。但是你有一个额外的DIV没有关闭。

我不认为这会影响PHP,但只是建议。如果我们也看到您的PHP代码的一部分,这将有所帮助。

您的HTML代码看起来不错。但您还没有提供任何PHP代码。

我发现的一些东西(当我得到这个错误时)是

  • 您的"密码"变量是在php脚本中获得的吗
  • 密码的大写是否正确(密码和非密码)

您能在php脚本的一开始就回显/打印$password变量吗?