我的index.php
页面中有以下表格
<form action='login.php' method='POST'>
Log in Here:<br><br>
Username:<input type='text' name='User_name' value='username' onFocus="clearText(this)" id='fn'>
<br><br>
Password:<input type='password' name='_password' ><br><br>
<input value='Log in' type="image" src="client-login-buttonclient-login-button.jpg" ><br><br>
<input type="checkbox" name="checkbox" id="checkbox" />
Remember password</span></p>
</form>
我将表单字段发布到另一个名为login.php
<?php
session_start();
$username=$_POST['User_name'];
$password=$_POST['_password'];
if($username && $password){
echo $username;
echo $password;
}
else {
echo 'A field is empty';
}
但是当我这样做时,它给了我以下错误
Notice: Undefined index: User_name in login.php on line 4
Notice: Undefined index: _password in login.php on line 5
为什么 post 方法不起作用?