PHP loads blank...looked for answer in other forums...
Moderator: General Moderators
-
Moomancow3k
- Forum Newbie
- Posts: 7
- Joined: Fri Apr 14, 2006 9:05 am
PHP loads blank...looked for answer in other forums...
Hey guys,
Sorry if this is an old problem...
I'm just trying to implement a simple login script.
However, whenever I submit the username/password, and have the script forward to check_login.php, that page loads blank. check_login.php is clearly on the server ( I can definatly see it), but after trying to login, I see only a blank page.
Try it here:
http://www.sis.pitt.edu/~ug41/with_login/login.php (just press "Log In" to see what I mean).
Any ideas??
Sorry if this is an old problem...
I'm just trying to implement a simple login script.
However, whenever I submit the username/password, and have the script forward to check_login.php, that page loads blank. check_login.php is clearly on the server ( I can definatly see it), but after trying to login, I see only a blank page.
Try it here:
http://www.sis.pitt.edu/~ug41/with_login/login.php (just press "Log In" to see what I mean).
Any ideas??
-
Moomancow3k
- Forum Newbie
- Posts: 7
- Joined: Fri Apr 14, 2006 9:05 am
login.php script...
feyd | Please use
Thanks for anyone's time in advance....I appreciate it.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Here is the script (I bet hard to read...sorry...)...Code: Select all
<?php
session_start();
$_SESSION['active'] = 1;
if ($_COOKIE["usersNameCookie"]){ # If this is true, then we have a returning user!!
echo "In oldUser confirmed loop.<br/>";
$oldUsersName = $_COOKIE["usersNameCookie"];
show_header();
show_oldUserScreen();
show_end();
}
$option = $_SESSION['option'];
$info = $_COOKIE['zany'];
if ($_COOKIE['zany[password]']):
foreach ($_COOKIE as $key => $value):
if (is_array($value)):
echo "$key is an array: <br />";
foreach ($value as $key2 => $value2):
echo "$key2: $value2 <br />";
endforeach;
else:
echo "$key : $value <br />";
endif;
endforeach;
endif;
if ($option){ #if this is TRUE, then user is in a session!!
if (strcmp($option, 'info') == 0){ # If there is no info, then do this
# to fill the info fields and set the
# cookie!!
if ($_POST['name']) {
$info['name'] = $_POST['name'];
$info['password'] = $_POST['password'];
$name = $info['name'];
$password = $info['password'];
# This sets the cookie on the client side. 600ms = 10min.
# After 10 min., the cookie will expire, and the user will have to
# re-enter their username and password.
# This sets the users email Address to a cookie and puts it on their computer!
setcookie("zany[name]", $name, time()+600);
echo "Just set cookie!<br/>";
$_SESSION['info'] = $info;
$_SESSION['option'] = "choice"; #This is done so now the server knows
#to show the choice options through
#the next iteration, and not prompt
#the user for their name and password
#again.
show_header();
show_menu();
show_end();
}
elseif (! $_SESSION[active]) { # Something went wrong - so end the session!!
show_header();
echo "Invalid Session -- closing it because Session[active] is FALSE! <br />";
show_end();
unset($_SESSION["option"]);
unset($_SESSION["info"]);
unset($_SESSION["history"]);
session_destroy();
}
else {
show_header();
echo "Invalid Session -- closing it because else has been hit. <br />";
show_end();
unset($_SESSION["option"]);
unset($_SESSION["info"]);
unset($_SESSION["history"]);
session_destroy();
}
} # This ends the the option info
else { # user should have made a choice!!
if (! $_COOKIE["usersNameCookie"]){
echo "You may log out below and log back on under a different
user name.";
?>
<form name = "logout"
action = "logout.php"
method = "POST">
<input type = "submit" value = "Log Out">
</form>
<?php
}
}
}
else { # Assuming No cookies here....show login!!
$_SESSION['option'] = 'info';
$_COOKIE['zany'] = 'assignedThisToCookie';
show_header();
show_login();
show_end();
}
function show_end() {
echo "</html>";
}
function show_header()
{
?>
<html>
<head>
<title>Art</title>
</head>
<?php
}
function get_info() {
echo "This is your first visit to the Primative Shopping Service. <br />";
echo "Please enter you're login information. (inside get_info() !!)";
}
function show_login() {
echo "Please enter in your login information below. <br />";
?>
<form name = "loginform"
action = "check_login.php"
method = "POST">
Email Address:<br /> <input type = "text" name = "name"> <br />
Password:<br /> <input type = "password" name = "password"> <br />
<input type = "submit" value = "Log in"> <br />
<a href="newUser.php">If you are New User, register here!</a><br />
</form>
<?php
}
function show_oldUserScreen() {
$_SESSION['oldUser'] = 1;
$oldUsersName = $_COOKIE["usersNameCookie"];
echo "Welcome back $oldUsersName! <br />";
echo "Please enter your password below to log back in! <br />";
?>
<form name = "oldUserloginform"
action = "check.php"
method = "POST">
Password: <input type = "password" name = "password"> <br />
<input type = "submit" value = "Log back in">
</form>
<form name = "logout"
action = "logout.php"
method = "POST">
<input type = "submit" value = "Log Out">
</form>
<i>Note: if you are a different customer, you must log out and</i><br />
<i>log back in using your email address and password!</i><br/>
<?php
}
?>Thanks for anyone's time in advance....I appreciate it.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]-
Moomancow3k
- Forum Newbie
- Posts: 7
- Joined: Fri Apr 14, 2006 9:05 am
Yea, I noticed no cookies are being set, but regardless, it should still forward to the next page and still show at least some HTMl...right??
I'm not sure how to check my error logs...
I'm working on this for my final group project in one of my classes...I believe I need to change something in the php.ini file to see errors, and I can't access that, because I don't maintain the server (the school does).
I'm not sure how to check my error logs...
I'm working on this for my final group project in one of my classes...I believe I need to change something in the php.ini file to see errors, and I can't access that, because I don't maintain the server (the school does).
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
put
at the top of your page, you should of done this already tbh
Code: Select all
error_reporting (E_ALL);-
Moomancow3k
- Forum Newbie
- Posts: 7
- Joined: Fri Apr 14, 2006 9:05 am
-
Moomancow3k
- Forum Newbie
- Posts: 7
- Joined: Fri Apr 14, 2006 9:05 am
I saw some syntax for this function, and I don't think I'm suppose to use the underscore, so I changed the line to this at the top of my scripts:
error_reporting (E ALL);
...however, now my login page, which loaded before, is now loading as a blank HTML page....
once again, are my errors written out to some other file somewhere?
error_reporting (E ALL);
...however, now my login page, which loaded before, is now loading as a blank HTML page....
once again, are my errors written out to some other file somewhere?
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
The underscore is required. Run the following in a new file and tell us the results please.
Code: Select all
<?php
$ve = phpversion();
$os = PHP_OS;
$er = intval(error_reporting());
$rg = (in_array(strtolower(ini_get('register_globals')), array(0, false, '', null, 'off')) ? 'Off' : 'On');
$de = (in_array(strtolower(ini_get('display_errors')), array(0, false, '', null, 'off')) ? 'Off' : 'On');
$so = (in_array(strtolower(ini_get('short_open_tag')), array(0, false, '', null, 'off')) ? 'Off' : 'On');
$eol = (isset($_SERVER['HTTP_HOST']) ? "<br />\n" : "\n");
$ec = array(
'E_STRICT' => 2048,
'E_ALL' => 2047,
'E_USER_NOTICE' => 1024,
'E_USER_WARNING' => 512,
'E_USER_ERROR' => 256,
'E_COMPILE_WARNING' => 128,
'E_COMPILE_ERROR' => 64,
'E_CORE_WARNING' => 32,
'E_CORE_ERROR' => 16,
'E_NOTICE' => 8,
'E_PARSE' => 4,
'E_WARNING' => 2,
'E_ERROR' => 1,
);
$e = array();
$t = $er;
foreach ($ec as $n => $v)
{
if (($t & $v) == $v)
{
$e[] = $n;
$t ^= $v;
}
}
$er = $er . ' (' . implode(' | ', $e) . ')';
echo 'PHP Version: ' . $ve . $eol;
echo 'PHP OS: ' . $os . $eol;
echo 'Error Reporting: ' . $er . $eol;
echo 'Register Globals: ' . $rg . $eol;
echo 'Short Tags: ' . $so . $eol;
echo 'Display Errors: ' . $de . $eol;
?>-
Moomancow3k
- Forum Newbie
- Posts: 7
- Joined: Fri Apr 14, 2006 9:05 am
-
Moomancow3k
- Forum Newbie
- Posts: 7
- Joined: Fri Apr 14, 2006 9:05 am