0

I get this error and have tried all steps to eliminate it but can't, have also tried the steps demonstrated on stack overflow but to no avail: error:

Parse error: syntax error, unexpected end of file in C:\wamp\www\project-Feedback form\project docs\login.php on line 80

I have attached the entire snippet of code:

<?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>
halfer
  • 19,824
  • 17
  • 99
  • 186
Abhilash Hande
  • 19
  • 1
  • 1
  • 2
  • 6
    Using proper indentation you shouldn't run into issues like this, have a read up of [this question which shows the guidelines](http://stackoverflow.com/questions/1155799/how-to-properly-indent-php-html-mixed-code) – Bankzilla Mar 09 '15 at 23:10
  • I think you need one more `}` at the end. – StackSlave Mar 09 '15 at 23:10
  • 4
    You are missing a closing brace. Do yourself a favour, and use an IDE with syntax highlighting (and code indenting). – Steve Mar 09 '15 at 23:11
  • @Steve will bear this is mind...just began working with php! – Abhilash Hande Mar 09 '15 at 23:13
  • You can remove the `stripslashes()` calls - that's only to cater for a legacy mode that PHP no longer uses ([magic quotes](https://php.net/manual/en/security.magicquotes.php)). You should swap the query concatenation for parameter binding anyway, so you don't need to do manual escaping. Also, don't store passwords in plain text - it exposes your users to too much risk if you get hacked - keep them hashed using an appropriate algorithm. – halfer Mar 10 '15 at 00:07

1 Answers1

7

You're missing a closing brace } for one of your conditional statements, being for this one:

if (isset($_POST['submit']))
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Micael Dias
  • 331
  • 2
  • 12