请求方法未定义

时间:2016-07-18 13:14:04

标签: php

我是PHP的新手。我一直在写一个登录脚本,它一直给我一个错误。这是代码。

登录HTML表单

<!DOCTYPE html>
<html>
<head>
	<title>LOG IN FORM</title>
	<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
	<div id="mainhead">
		<p>LOG IN FORM</p>
	</div>
	<div id= "mainbody">
		<form class="formdeco" action="log.php" method="POST">
			<table>
				<tr>
					<td> Email Address </td>
					<td><input type= "text" value="email" name="email"></td>
				</tr>
				<tr>
					<td> Password </td>
					<td><input type= "password" value="pwd" name="pwd"></td>
				</tr>
				<tr>
					<td>  </td>
					<td><input type= "submit" value="Login" name="logsubmit"></td>
				</tr>
			</table>
		</form>
	</div>
</body>
</html>

登录脚本

<?php
include 'connect.php';
	session_start();
	if ($_SERVER["REQUEST METHOD"] == 'POST') {
		//remove mysql injection
		$email = mysqli_real_escape_string($con, $_POST['email']);
		$pwd = mysqli_real_escape_string($con, $_POST['pwd']);
		$query = "SELECT id FROM signup_tbl WHERE Email ='$email' and Password = '$pwd'";
		$result = mysqli_query ($con, $query);
		$row = mysqli_fetch_array($result, $MYSQL_ASSOC);
		$count = mysqli_num_rows($result);
		if ($count == 1){
			$_SESSION ['login_user'] = $email;
			header('Location: welcome

<!-- begin snippet: js hide: false console: true babel: false -->

欢迎光盘

<?php
	if (!isset($_SESSION['login_user'])){
		header('Location: login.php');

	}
	else {
		$login_session = $_SESSION['login_user'];

	}
	?>
<!DOCTYPE html>
<html>
<head>
	<title>DASHBOARD</title>
	<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
	<div id="mainhead">
		<p>USERS PROFILE</p>
	</div>
	<div id= "mainbody">
		<p> LOG IN SUCCESSFUL... WELCOME <?php echo $login_session; ?>!!! </p>
	</div>
</body>

当我运行代码时,它给出的错误是: 注意:未定义的索引:第4行的C:\ xampp \ htdocs \ breakdown \ login_script.php中的REQUEST METHOD。

提前致谢...

3 个答案:

答案 0 :(得分:2)

您错过了_上的REQUEST_METHOD:)

答案 1 :(得分:1)

使用REQUEST_METHOD而非REQUEST METHOD您错过了_

答案 2 :(得分:0)

你错过了一个下划线。

try {
    if (from.exists()) {
        FileUtils.copyFileToDirectory(from, to);
        long size = from.length();

        System.out.println("rr" + size);
    } else { 
        System.out.println("No file");

    }
}