Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,674 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,201 people online right now. Registration is fast and FREE... Join Now!




Blank Page of Death

 
Reply to this topicStart new topic

Blank Page of Death, redirect syntax?

supersssweety
post 16 Jul, 2007 - 01:44 PM
Post #1


D.I.C Regular

Group Icon
Joined: 16 Mar, 2007
Posts: 312



Dream Kudos: 125
My Contributions


when a user logs in succesfully it is sent to thie page w/ this code:

CODE

<?php  
error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
ini_set("display_errors", "1");
?>
<?php
if (!isset($_SESSION)) {
  session_start();
}

$_SESSION['MM_UserGroup'] = $access_level;
switch ($access_level]) {
    case "eti":
         header( 'Location: http://www.webtestinglab.com/eti' )
         break;
    case "eti2":
         header( 'Location: http://www.webtestinglab.com/eti2')
         break;
    case "eti3":
         header( 'Location: http://www.webtestinglab.com/eti3' )
         break;
    default:
         header( 'Location: http://www.webtestinglab.com/sorry.php' );
}
?>


and there is no error reporting or anything.

[mod edit] What is so hard to get about code tags? I really don't get it.
User is offlineProfile CardPM

Go to the top of the page

girasquid
post 17 Jul, 2007 - 12:04 AM
Post #2


Barbarbar

Group Icon
Joined: 3 Oct, 2006
Posts: 1,256



Thanked 14 times

Dream Kudos: 650
My Contributions


When is the $access_level variable getting set? I see it being stored into a variable, but I don't see it being set anywhere. I also think you might want to change this:
CODE

switch ($access_level]) {

To this:
CODE

switch ($access_level) {

* If you can't see what I changed, I took out the right square brace from inside your switch statement.

This post has been edited by girasquid: 17 Jul, 2007 - 12:05 AM
User is offlineProfile CardPM

Go to the top of the page

supersssweety
post 17 Jul, 2007 - 06:12 AM
Post #3


D.I.C Regular

Group Icon
Joined: 16 Mar, 2007
Posts: 312



Dream Kudos: 125
My Contributions


thanks, yeah I caught that after I posted...didn't help...it is being declared from a session variable...I am very new and I am just winging it, my boss uses cold fusion, but this clients host doesn't support it...we are just trying to protect some folders, this is a dummy system just to see if we can get it working. eti is essentially going to be folder that when you go to its index you are redirected to a login page...i got that working, we used dreamweaver to make the code and then tweaked it. We have a table that just has the password and a user access level of eti eti2 eti3, and then passwords to go with it

...all we are trying to do is make them put in a password to access the folder. There is one password for each folder so the users will all have the same password for one folder. The problem with the login, is you can get through using any of the three passwords....but the code I sent you guys is the page it goes to when you get through the login, it should redirect back to the folder they were trying to access. I could make it automatically redirect back to the page they came from and that works just fine....but what if they bookmark the login.php page, and go directly to it, if I don't do the code in the success.php page I posted, then they won't have anywhere to go back so this just ensures they go where they should based off the password...which you can use any of the three passwords right now...but I am going to work that out once I get the redirects working...

$access_level is defined from a session variable:
<code>
$_SESSION['MM_UserGroup'] = $access_level;
</code>

I don't have a clue about sessions and session variables...I am going to be studing that this morning. Any help would be welcome
User is offlineProfile CardPM

Go to the top of the page

supersssweety
post 17 Jul, 2007 - 07:22 AM
Post #4


D.I.C Regular

Group Icon
Joined: 16 Mar, 2007
Posts: 312



Dream Kudos: 125
My Contributions


ok so I figured otu what was wrong...I changed the code to this:

CODE

<?php
if (!isset($_SESSION)) {
  session_start();
}
switch ($_SESSION['MM_UserGroup']) {
    case "eti":
         header('Location: http://www.webtestinglab.com/eti/index.php')
         break;
    case "eti2":
         header('Location: http://www.webtestinglab.com/eti2/index.php')
         break;
    case "eti3":
         header('Location: http://www.webtestinglab.com/eti3/index.php')
         break;
    default:
         header('Location: http://www.webtestinglab.com/sorry.php');
}
?>


but that session variable holds 3 values, not just the access level....here is the code that creates that session variable in the login page

CODE

$LoginRS__query=sprintf("SELECT UserName, Password, Access_Level FROM eti WHERE UserName=%s AND Password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
  
  $LoginRS = mysql_query($LoginRS__query, $XXXXXX) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
    
    $loginStrGroup  = mysql_result($LoginRS,0,'Access_Level');
    
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
                $_SESSION['MM_UserGroup'] = $loginStrGroup;


how do I pull the access level only out of the database and put it into a session variable? I know what I need to do, I just have little exp w/ PHP and how it works and syntax

This post has been edited by supersssweety: 17 Jul, 2007 - 09:29 AM
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 17 Jul, 2007 - 07:48 AM
Post #5


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,178



Thanked 33 times

Dream Kudos: 25
My Contributions


CODE

$LoginRS__query=sprintf("SELECT Access_Level FROM eti WHERE UserName=%s AND Password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
//other code
$_SESSION['MM_UserGroup'] = $loginStrGroup;

you're just modifying the query...
User is offlineProfile CardPM

Go to the top of the page

supersssweety
post 17 Jul, 2007 - 08:32 AM
Post #6


D.I.C Regular

Group Icon
Joined: 16 Mar, 2007
Posts: 312



Dream Kudos: 125
My Contributions


I printed what was in that variable and yes it was just the access level...but why the blank screen? that page just gives a blank screen...nothing on it

This post has been edited by supersssweety: 17 Jul, 2007 - 08:34 AM
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 17 Jul, 2007 - 08:49 AM
Post #7


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,178



Thanked 33 times

Dream Kudos: 25
My Contributions


Have you verified that nothing is being sent before the header call? If any output is sent prior to the header call, the action will likely not occur.

http://ca.php.net/header

User is offlineProfile CardPM

Go to the top of the page

supersssweety
post 17 Jul, 2007 - 09:07 AM
Post #8


D.I.C Regular

Group Icon
Joined: 16 Mar, 2007
Posts: 312



Dream Kudos: 125
My Contributions


I finally fixed it, i got the switch syntax from God knows where, but I wasmissing three ; it works fine now, I feel stupid cause I knew from working w/ drupal that blank page meant you were missing something simple like a ; or a [ or a ) 3 hours wasted...my instinct was to put the ; on the end of those headers too, but the syntax i had looked at had them only after the break...thanks for your help
User is offlineProfile CardPM

Go to the top of the page

snoj
post 17 Jul, 2007 - 01:08 PM
Post #9


$Null

Group Icon
Joined: 31 Mar, 2003
Posts: 3,304



Thanked 5 times

Dream Kudos: 700
My Contributions


Damn those semi-colons!

As for why there were no errors being shown, it's likely the server has it setup so that no errors are shown in the first place. So therefore if you have an error with your code and even though you have error_reporting set to all, it won't since the code contains a fatal syntax error and thus no code is actually run from the script.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 06:23AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month