ublapach Posted April 26, 2008 Share Posted April 26, 2008 Help got an error think im doing this right can you help i want a login system to have a different header page for each user based on access level heres the code i got so far im getting and error Parse error: parse error, unexpected $ on line 60 of this file <?php require_once "../tracking/db_connx.php"; session_start(); if (isset ($_POST['submit'])) { if (preg_match('/[!@#$%^&*()-+=`~<>,.?}{|]/', $_POST['username'])) { echo "Illegal Characters In Username"; } else { if (preg_match('/[!@#$%^&*()-+=`~<>,.?}{|]/', $_POST['passwd'])) { echo "Illegal Characters In Password"; } else { $username = $_POST['username']; $password = $_POST['passwd']; $sql = "SELECT * FROM webusers WHERE username='$username' AND passwd='$passwd'"; if ($r = mysql_query ($sql)) { $row = mysql_fetch_array ($r); $num = mysql_num_rows ($r); if ($num > 0) { @$_SESSION['username'] = $row['username']; @$_SESSION['fname'] = $row['fname']; @$_SESSION['lname'] = $row['lname']; @$_SESSION['email'] = $row['email']; @$_SESSION['accesslvl'] = $row['accesslvl']; @$_SESSION['logged_in'] = TRUE; $cookiename = 'ceiscorp.com'; $cookievalue=rand(100000,999999); $_SESSION['cookieverify'] = $cookievalue; setcookie($cookiename,$cookievalue,time()+3600,"/"); $today=date('r'); mysql_query("UPDATE webusers SET logged_in = '$today' WHERE username = '$username'") or die (mysql_error()); if($_SESSION['accesslvl'] = 'admin'){ header("Location:../indexadmin.php"); exit;} else if($_SESSION['accesslvl'] = 'ceis'){ header("Location:../indexceis.php"); exit;} else if($_SESSION['accesslvl'] = 'cust'){ header("Location:../indexcust.php"); exit; }else{ @$_SESSION['problem'] ="Username or Password are Incorrect Please Try again"; header ('Location: ../indexlog.php'); exit; } } } } } ?> Link to comment https://forums.phpfreaks.com/topic/103019-login-based-on-access-level/ Share on other sites More sharing options...
paul2463 Posted April 26, 2008 Share Posted April 26, 2008 you were missing a closing brace on one of you if / else statement, if you organised your code a wee bit better with proper indentations and opening a closing braces on the same tab then you would spot the ones that were missing, just a minor observation <?php require_once "../tracking/db_connx.php"; session_start(); if (isset ($_POST['submit'])) { if (preg_match('/[!@#$%^&*()-+=`~<>,.?}{|]/', $_POST['username'])) { echo "Illegal Characters In Username"; } else { if (preg_match('/[!@#$%^&*()-+=`~<>,.?}{|]/', $_POST['passwd'])) { echo "Illegal Characters In Password"; } else { $username = $_POST['username']; $password = $_POST['passwd']; $sql = "SELECT * FROM webusers WHERE username='$username' AND passwd='$passwd'"; if ($r = mysql_query ($sql)) { $row = mysql_fetch_array ($r); $num = mysql_num_rows ($r); if ($num > 0) { @$_SESSION['username'] = $row['username']; @$_SESSION['fname'] = $row['fname']; @$_SESSION['lname'] = $row['lname']; @$_SESSION['email'] = $row['email']; @$_SESSION['accesslvl'] = $row['accesslvl']; @$_SESSION['logged_in'] = TRUE; $cookiename = 'ceiscorp.com'; $cookievalue=rand(100000,999999); $_SESSION['cookieverify'] = $cookievalue; setcookie($cookiename,$cookievalue,time()+3600,"/"); $today=date('r'); mysql_query("UPDATE webusers SET logged_in = '$today' WHERE username = '$username'") or die (mysql_error()); if($_SESSION['accesslvl'] = 'admin') { header("Location:../indexadmin.php"); exit; } else if($_SESSION['accesslvl'] = 'ceis') { header("Location:../indexceis.php"); exit; } else if($_SESSION['accesslvl'] = 'cust') { header("Location:../indexcust.php"); exit; } } else { @$_SESSION['problem'] ="Username or Password are Incorrect Please Try again"; header ('Location: ../indexlog.php'); exit; } } } } } ?> Link to comment https://forums.phpfreaks.com/topic/103019-login-based-on-access-level/#findComment-527827 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.