-3

need some help with the code below. This the part of a php code to check if the combination of the user ID and encrypted password are already in the database. So when I run the code with Xampp, an error - Parse error: syntax error, unexpected '}' occurred.

<?php
//Determine if the User ID and password are on file.
    $row = mysql_fetch_object($result);
    $db_userid = $row->admin_id;
    $db_password = $row->admin_password;
    $name = $row->admin_name;

if($db_userid != $userid || $db_password != $encryptpasswd){

    //If not on file, add record to administrator table.
    $query = "INSERT INTO administrator(admin_id, admin_password, admin_name)
                VALUES('$userid','$encryptpasswd','$name')";
    $result = mysql_query($query)
        or die("Insert to administrator failed." . mysql_error());

    //Return to adminAuthen.php
    header( "Location: adminAuthen.php");
}
else{
    //If on file, set the session variable, and enter site.
    $_SESSION["name"] = $name;
    $_SESSION["retry"] = "admit";
    $_SESSION["time"] = time();
    header( "Location: /ClassRegistration/Maintenance/systementry.php")
}
?>

Thank you :)

NineKyu
  • 3
  • 1

2 Answers2

0

Apply a semi colon after header function

header( "Location: /ClassRegistration/Maintenance/systementry.php");

Ashish Choudhary
  • 2,004
  • 1
  • 18
  • 26
0

You forgot a ; after this line header( "Location: /ClassRegistration/Maintenance/systementry.php")

The correct code should be:

header( "Location: /ClassRegistration/Maintenance/systementry.php");

on a futher note: Please do not use mysql_query to connect to your database. This is very unsafe and will be removed in the next version of PHP. This means you code is going to break very soon.

Please look at the following page for more information: MySQL vs MySQLi when using PHP

Community
  • 1
  • 1
AgeDeO
  • 3,137
  • 2
  • 25
  • 57