coldfiretech Posted August 21, 2008 Share Posted August 21, 2008 For some reason this wont work with the top bit of code so i had to comment it out.. Everything else works but the commented code. When i try to login with a fresh user it just sits at a blank page and doesnt do anything... Im not sure what is going on.. Any help would be greatly appreciated Thanks ;D <?php session_start(); $loggedin = $_COOKIE['loggedin']; $subtype = $_COOKIE['subtype']; //if ($loggedin=="yes") { // echo "you are already logged in"; // // redirect to correct panel // if ($subtype=="single") { // print "<META HTTP-EQUIV=\"refresh\" content=\"2; URL=/cellsavior/single_plan_panel.php\">"; // } // // if ($subtype=="partner") { // print "<META HTTP-EQUIV=\"refresh\" content=\"2; URL=/cellsavior/partner_plan_panel.php\">"; // } // // if ($subtype=="family") { // print "<META HTTP-EQUIV=\"refresh\" content=\"2; URL=/cellsavior/family_plan_panel.php\">"; // // } else { //do login $db_host = 'localhost'; $db_user = '******; $db_pass = '*****; $db_db = '*******'; $con = mysql_connect($db_host, $db_user, $db_pass) or die('MySQl Connection Error:'.mysql_error()); mysql_select_db($db_db, $con) or die('MySQL Error: Cannot select table'); $user = mysql_real_escape_string($_POST['login']); $password = mysql_real_escape_string($_POST['password']); $sid = $_POST['login']; $q = " SELECT login, subtype, id FROM `users` Where login = '".$user."' AND password = '".$password."' "; $r = mysql_query($q,$con) or die(mysql_error()."<br /><br />".$q); if(mysql_num_rows($r) >0){ $row = mysql_fetch_assoc($r); $_SESSION['login'] = $sid; // store session data setcookie("loggedin", "yes"); switch ($row['subtype']){ case "single": setcookie("subtype", "single"); die(header("location: /cellsavior/single_plan_panel.php")); break; case "partner": setcookie("subtype", "partner"); die(header("location: /cellsavior/partner_plan_panel.php")); break; case "family": setcookie("subtype", "family"); die(header("location: /cellsavior/family_plan_panel.php")); break; default: die(header("location: index.html?msg=invalid subtype")); if(isset($_SESSION['login'])) unset($_SESSION['login']); setcookie("loggedin", "", time()-3600); } } else{ die(header("location: index.html?msg=invalid login")); if(isset($_SESSION['login'])) unset($_SESSION['login']); setcookie("loggedin", "", time()-3600); } mysql_close ($con); //} //} ?> Link to comment https://forums.phpfreaks.com/topic/120767-solved-multi-level-user-login-system-not-working/ Share on other sites More sharing options...
lemmin Posted August 21, 2008 Share Posted August 21, 2008 Try this: if ($loggedin=="yes") { echo "you are already logged in"; // redirect to correct panel if ($subtype=="single") { header("Location: /cellsavior/single_plan_panel.php"); } if ($subtype=="partner") { header("Location: /cellsavior/partner_plan_panel.php"); } if ($subtype=="family") { header("Location: /cellsavior/family_plan_panel.php"); } else { do login Link to comment https://forums.phpfreaks.com/topic/120767-solved-multi-level-user-login-system-not-working/#findComment-622465 Share on other sites More sharing options...
coldfiretech Posted August 21, 2008 Author Share Posted August 21, 2008 tried that... still nothing.. just sits at a blank page. Link to comment https://forums.phpfreaks.com/topic/120767-solved-multi-level-user-login-system-not-working/#findComment-622473 Share on other sites More sharing options...
lemmin Posted August 21, 2008 Share Posted August 21, 2008 Probably because errors are off and you have whitespaces (or other content) before your <?php openning tag. Make sure '<' is the very first character of the file. Link to comment https://forums.phpfreaks.com/topic/120767-solved-multi-level-user-login-system-not-working/#findComment-622477 Share on other sites More sharing options...
coldfiretech Posted August 21, 2008 Author Share Posted August 21, 2008 that just because i hit enter a few times before i dropped my code into the "['code']" tags Link to comment https://forums.phpfreaks.com/topic/120767-solved-multi-level-user-login-system-not-working/#findComment-622480 Share on other sites More sharing options...
coldfiretech Posted August 21, 2008 Author Share Posted August 21, 2008 i took out all whitespaces and it still doesnt work... Anyone??? Link to comment https://forums.phpfreaks.com/topic/120767-solved-multi-level-user-login-system-not-working/#findComment-622516 Share on other sites More sharing options...
BlueSkyIS Posted August 21, 2008 Share Posted August 21, 2008 Probably because errors are off Link to comment https://forums.phpfreaks.com/topic/120767-solved-multi-level-user-login-system-not-working/#findComment-622518 Share on other sites More sharing options...
coldfiretech Posted August 21, 2008 Author Share Posted August 21, 2008 and how do i fix that?? <--NEW TO PHP (Just started 2 days ago!) Link to comment https://forums.phpfreaks.com/topic/120767-solved-multi-level-user-login-system-not-working/#findComment-622522 Share on other sites More sharing options...
akitchin Posted August 21, 2008 Share Posted August 21, 2008 you aren't closing your brace on that third if() statement. to learn how to turn errors on, have a look at this tutorial: http://www.phpfreaks.com/tutorial/debugging-a-beginners-guide Link to comment https://forums.phpfreaks.com/topic/120767-solved-multi-level-user-login-system-not-working/#findComment-622526 Share on other sites More sharing options...
coldfiretech Posted August 21, 2008 Author Share Posted August 21, 2008 Thanks i have changed my code to this and now nothing works. The errors i get are Notice: Undefined index: loggedin in C:\wamp\www\cellsavior\userAuth2.php on line 5 Notice: Undefined index: subtype in C:\wamp\www\cellsavior\userAuth2.php on line 6 <?php ini_set('display_errors','On'); error_reporting(E_ALL); session_start(); $loggedin = $_COOKIE['loggedin']; $subtype = $_COOKIE['subtype']; if ($loggedin=="yes") { echo "you are already logged in"; // redirect to correct panel if ($subtype=="single") { header("Location: /cellsavior/single_plan_panel.php"); } if ($subtype=="partner") { header("Location: /cellsavior/partner_plan_panel.php"); } if ($subtype=="family") { header("Location: /cellsavior/family_plan_panel.php"); } else { //do login $db_host = 'localhost'; $db_user = '****'; $db_pass = '********'; $db_db = '*******'; $con = mysql_connect($db_host, $db_user, $db_pass) or die('MySQl Connection Error:'.mysql_error()); mysql_select_db($db_db, $con) or die('MySQL Error: Cannot select table'); $user = mysql_real_escape_string($_POST['login']); $password = mysql_real_escape_string($_POST['password']); $sid = $_POST['login']; $q = " SELECT login, subtype, id FROM `users` Where login = '".$user."' AND password = '".$password."' "; $r = mysql_query($q,$con) or die(mysql_error()."<br /><br />".$q); if(mysql_num_rows($r) >0){ $row = mysql_fetch_assoc($r); $_SESSION['login'] = $sid; // store session data setcookie("loggedin", "yes"); switch ($row['subtype']){ case "single": setcookie("subtype", "single"); die(header("location: /cellsavior/single_plan_panel.php")); break; case "partner": setcookie("subtype", "partner"); die(header("location: /cellsavior/partner_plan_panel.php")); break; case "family": setcookie("subtype", "family"); die(header("location: /cellsavior/family_plan_panel.php")); break; default: die(header("location: /cellsavior/index.html?msg=invalid subtype")); if(isset($_SESSION['login'])) unset($_SESSION['login']); setcookie("loggedin", "", time()-3600); } } else{ die(header("location: /cellsavior/index.html?msg=invalid login")); if(isset($_SESSION['login'])) unset($_SESSION['login']); setcookie("loggedin", "", time()-3600); } mysql_close ($con); } } ?> Link to comment https://forums.phpfreaks.com/topic/120767-solved-multi-level-user-login-system-not-working/#findComment-622535 Share on other sites More sharing options...
akitchin Posted August 21, 2008 Share Posted August 21, 2008 count the opening and closing braces. see anything wrong? if ($loggedin=="yes") { echo "you are already logged in"; // redirect to correct panel if ($subtype=="single") { header("Location: /cellsavior/single_plan_panel.php"); } if ($subtype=="partner") { header("Location: /cellsavior/partner_plan_panel.php"); } if ($subtype=="family") { header("Location: /cellsavior/family_plan_panel.php"); // <-- HOW ABOUT RIGHT HERE? } else { you're missing a closing brace on that third if(). Link to comment https://forums.phpfreaks.com/topic/120767-solved-multi-level-user-login-system-not-working/#findComment-622537 Share on other sites More sharing options...
coldfiretech Posted August 21, 2008 Author Share Posted August 21, 2008 thanks a bunch... Link to comment https://forums.phpfreaks.com/topic/120767-solved-multi-level-user-login-system-not-working/#findComment-622544 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.