It should just be a simple redirection
I have use this code before when I built a message board for my final project in PHP class, so I KNOW that the code has worked in the past. But it sure doesn't now, and everywhere I turn to gives me the same code or alternate suggestions that don't work.
I'm just trying to do a simple user login and redirection.
$query = "select userid, admin from $SQLtableName where username='$frmUserName'";
$result = mysql_query ($query);
$row = mysql_fetch_array ($result);
$_SESSION['sesLogIn'] = true;
$_SESSION['sesUserID'] = $row;
$_SESSION['sesAdmin'] = $row;
$_SESSION['sesUserName'] = $usertopass;
//print "<a href=http://www.2kcomm.com/newsite/members/members.php>link</a>";
It should redirect me to my members page, yes? But no, it directs me to the same page I'm on, but now the entire page is blank. That is, unless I take the comments off the '//print' line. Then it will bring up a blank page with the words 'link' on it. But if I press my link, for some reason my members page doesn't get passed the session variables.
I'm so confused, the code is before the HTML. There are no blank lines. My meta refresh is on. It has this problem on both PC and MAC, in IE and Safari. I know that Yahoo! Business Hosting's PHP server accepts HTTP commands, and in fact suggests the exact code I used to redirect users. I can't access the php.ini file, but I don't know if that would do anything even if I could.
If somebody wants to take a whack at it, please help:
username - marta
password - marta
I'm just getting tired seeing that f**king blank page.
madness I tell you madness
The members.php page used to have code that would redirect the user back to the login.php page if the login variable wasn't true in the session. However, I commented that out, when I figured out that the redirection wasn't working. It was giving me the same thing, no change in URL but the page became blank.
I do have a session start at the top of all my pages. I have tried redirecting to a page like Google and that doesn't work. And to top it all off, after continuing to try and build the members.php page last night and giving up a redirection at the moment, now my members.php page is showing up as blank. I can't even begin to guess why.
There is no redirection on the members.php page. All I added was a call to the database to try and fill in some information in a table. I'm adding below here, the code of the members.php page, and maybe if someone can figure out why it's now showing up as blank... it will answer the other question.
Here we go:
#Start the PHP session
#Variables set to log into SQL database
$SQLusername = 'fakeuesrname';
$SQLpassword = 'fakepassword';
$SQLdbname = 'fakedbname';
$SQLtableName = 'users';
$SQLtableName2 = 'messages';
$SQLtableName3 = 'servicecalls';
$db = mysql_connect("mysql", $SQLusername, $SQLpassword) or print mysql_error ();
mysql_select_db($SQLdbname) or print mysql_error ();
#Checks to see if user is logged in
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
Rest of code that got cut off
<img src="../images/members_hdr.gif" width="160" height="18">
<hr align="center" size="1" noshade>
#Prints login information into header
<div align="center"><strong>USER OPTIONS<br>
Oh... I figured THAT part out
okay the members.php page wasn't loading because...
"SELECT messageid, DATE_FORMAT(created,"%W, %b %D, %Y at %r"),
was supposed to be
"SELECT messageid, DATE_FORMAT(created,'%W, %b %D, %Y at %r'),
Ha, silly quotations... login.php problem still a problem though.
I got it I got it, I HATE Yahoo!
It's fixed, it's fixed. Figures I had to troubleshoot something completely different to solve my problem.
This is what Yahoo! has on the FAQ PHP help page:
Why arenít my session functions working?
When you create your PHP scripts, you will also need to create the "tmp" subdirectory in your account.
PHP's session functions store your visitor information in temporary files, which are written to the "tmp" directory. If this directory does not exist, the session information will not be stored.
Somehow, that made my redirect work... don't ask me why, because that redirection didn't ever work on my members.php page and that page has no SESSION variables???