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); //} //} ?> Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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??? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted August 21, 2008 Share Posted August 21, 2008 Probably because errors are off Quote Link to comment 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!) Quote Link to comment 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 Quote Link to comment 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); } } ?> Quote Link to comment 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(). Quote Link to comment Share on other sites More sharing options...
coldfiretech Posted August 21, 2008 Author Share Posted August 21, 2008 thanks a bunch... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.