Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Jan 2004
    Location
    Ann Arbor, MI
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy 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[0];
    $_SESSION['sesAdmin'] = $row[1];
    $_SESSION['sesUserName'] = $usertopass;
    //print "<a href=http://www.2kcomm.com/newsite/members/members.php>link</a>";
    header("Location: http://www.2kcomm.com/newsite/members/members.php");
    exit();

    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:
    http://www.2kcomm.com/newsite/members/login.php
    username - marta
    password - marta

    I'm just getting tired seeing that f**king blank page.

    Marta

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,071
    Thanks
    11
    Thanked 96 Times in 94 Posts
    are you starting the session somewhere ??
    session_start();

    if so , are you sure your page http://www.2kcomm.com/newsite/members/members.php is not itself redirecting you back to the login page ??

    eg at the very top of that page put

    PHP Code:
    <?
    session_start
    ();
    print_r($_SESSION);
    die();
    ?>
    to see
    1) if you even get there &
    2) if you do , do the expected session variables exist .

    If they don't I assume you check on that page for such and redirect to login?
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #3
    New to the CF scene
    Join Date
    Jan 2004
    Location
    Ann Arbor, MI
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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:
    <?php
    #Start the PHP session
    session_start ();
    include "codeLib.inc";

    #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
    #checklogin($sesLogIn,'http://www.2kcomm.com/newsite/members/login.php');
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>

  • #4
    New to the CF scene
    Join Date
    Jan 2004
    Location
    Ann Arbor, MI
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Rest of code that got cut off

    ...skipping ahead...

    <img src="../images/members_hdr.gif" width="160" height="18">
    <hr align="center" size="1" noshade>
    <?php
    #Prints login information into header
    #printlogin($sesLogIn,$sesUserName,$sesAdmin);
    ?>
    <div align="center"><strong>USER OPTIONS<br>

  • #5
    New to the CF scene
    Join Date
    Jan 2004
    Location
    Ann Arbor, MI
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cut off again???

    that last one I commented out, just in case it was causing trouble

    this next one is the new code I added

    <table width="100%" border="1" align="center" cellpadding="3" cellspacing="0" bordercolor="#585760" class="messageTable">
    <tr bgcolor="#393848">
    <td width="200" class="messageTable">&nbsp;&nbsp;MESSAGE TITLE </td>
    <td class="messageTable">&nbsp;&nbsp;AUTHOR</td>
    <td class="messageTable">&nbsp;&nbsp;DATE</td>
    <td class="messageTable">&nbsp;&nbsp;TOPIC</td>
    </tr>
    <?php
    ###########Refers to database table of Messages
    $query = "SELECT messageid, DATE_FORMAT(created,"%W, %b %D, %Y at %r"), rootid, userid, touserid, title FROM $SQLtableName2 WHERE userid = $sesUserID OR touserid = $sesUserID ORDER BY created;";
    $result = mysql_query ($query);

    ###########Lists Categories and their Descriptions
    while ($row = mysql_fetch_row ($result)) {
    print "<tr bgcolor='#4A4A59'><td bgcolor='#4A4A59' width=200 class='messageTable'>&nbsp;&nbsp;";
    ###########Makes them links to Category display page submitting Category into variable
    print "<a href='http://www.2kcomm.com/newsite/members/message.php?messageid=" . $row[0] . "'>";
    print $row[5] . "</a></td>";
    ###########Grabs the full name of the user who posted the message
    $query2 = "SELECT fullname FROM $SQLtableName WHERE userid = $row[3]";
    $result2 = mysql_query ($query2);
    while ($row2 = mysql_fetch_row ($result2)) {
    print "<td class='messageTable'>&nbsp;&nbsp;" . $row2[0] . "</td>";
    }
    print "<td class='messageTable'>&nbsp;&nbsp;" . $row[1] . "</td>";
    print "<td class='messageTable'>&nbsp;&nbsp;<a href='http://www.2kcomm.com/newsite/members/message.php?messageid=" . $row[2] . "'></td></tr>";
    }
    ?>
    </table>
    Last edited by tristess00; 01-15-2004 at 03:13 PM.

  • #6
    New to the CF scene
    Join Date
    Jan 2004
    Location
    Ann Arbor, MI
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #7
    New to the CF scene
    Join Date
    Jan 2004
    Location
    Ann Arbor, MI
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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???

    Marta

  • #8
    Regular Coder
    Join Date
    Jan 2004
    Location
    Georgia
    Posts
    306
    Thanks
    0
    Thanked 0 Times in 0 Posts
    figures.
    ~Designer's Toolz~


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •