Parse error: syntax error, unexpected ';' for login page

143 views Asked by At

I'm getting Parse error: syntax error, unexpected ';' on line 8.

<?php

    $userid=$_POST['userid'];
    $pswd=$_POST['pswd'];

    if ($userid==("admin") & $pswd==("123"))
    (
    $_SESSION['userid'] = $userid;
    $_SESSION['pswd'] = $pswd;
    header("location:admin.php");
    )

    else echo 'Ops! Please try again.';

    ?>

here's line 8

$_SESSION['userid'] = $userid;

sorry, I know this can be just minor error, but I'm getting blind. thank you for helping!

3

There are 3 answers

1
Code Lღver On BEST ANSWER

Your code is not correct use this:

$userid = $_POST['userid'];
$pswd = $_POST['pswd'];

if($userid == "admin" && $pswd == "123")
{
  $_SESSION['userid'] = $userid;
  $_SESSION['pswd'] = $pswd;
  header("Location: admin.php");
} else {
   echo 'Ops! Please try again.';
}
0
Ignacio Ocampo On

You need change your if (you are opening and closing with () and you need do it with {} )

if ($userid==("admin") && $pswd==("123"))
{
$_SESSION['userid'] = $userid;
$_SESSION['pswd'] = $pswd;
header("location:admin.php");
}
2
Vereos On

There are several errors on your if statement. You forgot a & and you must write instructions into { }.

It actually is

if ($userid=='admin' && $pswd=='123')
{
    //Instructions
}