如何修复"语法错误,意外的文件结束" PHP中的错误?

时间:2015-03-09 23:04:44

标签: php syntax-error

我收到此错误并尝试了所有步骤以消除它但是还没有尝试过堆栈溢出所示的步骤,但无济于事: 错误:

  

解析错误:语法错误,C:\ wamp \ www \ project中的意外文件结束 - 第80行的反馈表单\ project docs \ login.php

我附上了整段代码:



<?php
session_start(); // Starting Session
$error=''; // Variable To Store Error Message
?>

<html>
	<head>
		<title>Login Page</title>
		<link rel="stylesheet" type="text/css" href="login.css"> 

	</head>
	<body>
		<div id="header">
		<center><p><img src="http://www.ruparel.edu/_/rsrc/1338008090424/config/customLogo.gif?revision=29" align="left" /> <img id="image" src="http://www.auplod.com/u/pudlao4d2f7.png"  /> </p></center>
		
		</div>
		<hr></hr>
		<center><h1> Welcome to the Login page for <img src="http://www.auplod.com/u/uoalpd4d31a.png" /> </h1></center>
		<center><h2>Please Login!</h2></center>
	`	<br />
		
		<form method="post" action=" ">
		<div id="radio"><b><img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQMfjN-cd00MPhHqoKOKnUHp-VP3HSU3FBuuNDJbJL2yQF0fyWR"/>Student<input type="radio" name="radio1" value="Student"></p>
		<b><img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSSnk6-xJ7aCZL8aODuWyRMAENzk7XIFitACfPJALdJOaTzQq1b-w" />Professor<input type="radio" name="radio1" value="Professor"></b> </div>
		<div id="fields"><b>ROll no:<input type="text" name="username" ></b>
		<b>Password:<input type="password" name="pwd"></b><b>&nbsp;<input type="submit" name="submit" value="Login"></b></div>
		
		</form>
		
	<?php
		if (isset($_POST['submit'])) 
		{
		if (empty($_POST['username']) || empty($_POST['password'])) 
		{
		$error = "Username or Password is invalid";
		}
		else
		{
			// Define $username and $password
		$username=$_POST['username'];
		$password=$_POST['password'];
		// Establishing Connection with Server by passing server_name, user_id and password as a parameter
		$connection = mysqli_connect("localhost", "root", "");
		// To protect MySQL injection for Security purpose
		$username = stripslashes($username);
		$password = stripslashes($password);
		$username = mysqli_real_escape_string($username);
		$password = mysqli_real_escape_string($password);
		// Selecting Database
		$db = mysqli_select_db($connection,"feedback data");

		// SQL query to fetch information of registerd users and finds user match.
		$query = mysqli_query($connection,"select * from login where password='$password' AND username='$username'");
		$rows = mysqli_num_rows($query);
		if ($rows == 1) {
		$_SESSION['login_user']=$username; // Initializing Session
		//now we write php code to decide if student or teacher

		$subject=$_SESSION['login_user'];
		$pattern="/[2$]/";
		if($_POST['radio1']=="Professor"&& preg_match($pattern,$subject)==1)//condition for teacher using BRE
		{
			header("location: http://localhost/project-Feedback%20form/project%20docs/selection_page_teacher.php");
		}
		elseif($_POST['radio1']=="Student"&& preg_match($pattern,$subject)==0)//condition for student using BRE
		{
			header("location: http://localhost/project-Feedback%20form/project%20docs/selection_page_student.php");
		}
		else
		{
			echo"The selection you have made is incorrect Mr.".$_SESSION['login_user'];
		}
		mysql_close($connection); // Closing Connection
		}
		}
		
	?>
	</body>
</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:6)

你错过了一个条件语句的右括号},就是这个:

if (isset($_POST['submit']))
相关问题