Question

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!

Was it helpful?

Solution

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.';
}

OTHER TIPS

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");
}

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
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top