cfgcjm Posted September 30, 2007 Share Posted September 30, 2007 So i had this php login script: <?php /* Login Script */ require ('mysql.php'); session_start(); if (isset ($_POST['submit'])) { // Check to see if the form has been submitted $username = $_POST['username']; $password = md5 ($_POST['password']); // we MD5 encrypted the password at registration, // so we must do this on the login as well // See if the user exists $sql = "SELECT * FROM users WHERE username='$username' AND password='$password'"; if ($r = mysql_query ($sql)) { $row = mysql_fetch_array ($r); $num = mysql_num_rows ($r); if ($num > 0) { // if there is a row with that username/password, the user exists // Now we can assign some SESSIONS, so we can verify on later pages that the user is "logged in" $_SESSION['users_id'] = $row['users_id']; $_SESSION['username'] = $row['username']; $_SESSION['loggedin'] = TRUE; // This is where we will check to see if the user is logged in header("location:portal.php"); exit; } else { // User does not exist print 'Invalid Username/Password!'; } } else { // The query failed print 'Error:' . mysql_error(); // print the MySQL error } } else { // The form was not submitted // Display the form print '<form action="login.php" method="post"> <table border="0"> <tr> <td align="right">Username:</td> <td align="center"><input type="text" name="username" /></td> </tr> <tr> <td align="right">Password:</td> <td align="center"><input type="password" name="password" /></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" value="Submit" /></td> </tr> </table> </form>'; } ?> and it was working...I was playing around with some CSS style stuff and then it simply stopped working. I deleted the file and created a new one...and it still wouldn't work. What it does is it will log me in but it wont execute the header("Location:portal.php"); exit; it simply displays a blank white screen. If i replace header("Location:portal.php"); exit; with print 'Thank you for logging in!'; it works so it is my header command but i just dont get it any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/71206-script-not-working-as-expected/ Share on other sites More sharing options...
desithugg Posted September 30, 2007 Share Posted September 30, 2007 Does the css come before the php part. Because if you output anything to the browser before the redirect line php will not redirect. Example: <?php echo "Hey there"; header("location: saad.php"); exit; ?> The above will not work but if you do. <? header("location: saad.php"); exit; echo "Hey there"; ?> It will work. If that doesn't work try changing the header("location:portal.php"); to header("location: portal.php"); (put a space after location: Quote Link to comment https://forums.phpfreaks.com/topic/71206-script-not-working-as-expected/#findComment-358156 Share on other sites More sharing options...
cfgcjm Posted September 30, 2007 Author Share Posted September 30, 2007 That worked! but my issue now is how to format the php script ie font and text color? I have it on a dark background and can't see the text Quote Link to comment https://forums.phpfreaks.com/topic/71206-script-not-working-as-expected/#findComment-358162 Share on other sites More sharing options...
desithugg Posted September 30, 2007 Share Posted September 30, 2007 Umm link me to the page. Quote Link to comment https://forums.phpfreaks.com/topic/71206-script-not-working-as-expected/#findComment-358164 Share on other sites More sharing options...
cfgcjm Posted September 30, 2007 Author Share Posted September 30, 2007 http://www.stjohnsuccjonestown.org/portal/login.php it gets launched in a absolute size window so ignore the obnoxious repeating background Quote Link to comment https://forums.phpfreaks.com/topic/71206-script-not-working-as-expected/#findComment-358166 Share on other sites More sharing options...
desithugg Posted September 30, 2007 Share Posted September 30, 2007 Here try changing <td align="right">Username:</td> <td align="right">Password:</td> to <td align="right" style="color: #fff;">Username:</td> <td align="right" style="color: #fff;">Password:</td> Quote Link to comment https://forums.phpfreaks.com/topic/71206-script-not-working-as-expected/#findComment-358168 Share on other sites More sharing options...
cfgcjm Posted September 30, 2007 Author Share Posted September 30, 2007 ok and how about font and positioning on the page? I would normally just stick whatever i'm trying to move in a layer but that wont work for this because that would put code before the php. Quote Link to comment https://forums.phpfreaks.com/topic/71206-script-not-working-as-expected/#findComment-358171 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.