SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    sweden
    Posts
    646
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Header problem...

    I have a website and everything seems to work fine, except one small thing.
    I have a login form where user login. After submitting that form they'll be taken to a separate page, which is checking their details and they end up in different pages whether they have a level 1 or level 2 in their row.

    I also set the number of times they've been logged in here as well.

    But when it passes this page and move on, they end up in their specific page (let's say, either 1 or 2).
    On this new page I have a table with 2 columns.
    In the left column I have text parts and in the right column I have an include with things that is used all over the site (like visitors online, total members, and so on).

    But when I pass the login check page with the redirection part the stuff in the right column isn't showing. I only get "Failed!" in that area.
    Everything else on the page is loaded like it should and if I reload the page I can see the right column correct.

    So, it's gotta be something from the redirecting page I guess.

    This is what it looks like:

    PHP Code:
    mysql_query("UPDATE table_user SET usr_times=usr_times++1, usr_last=now() WHERE user_id='$usr_id'");
    mysql_free_result($rs_user);
    header("Location: index_1.php"); /* Redirect browser */
    exit; 
    So, anyone have an idea or recognize the problem?

  2. #2
    SitePoint Guru
    Join Date
    Sep 2004
    Posts
    613
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Show more of your code... perhaps the entire file if you can.

    I can tell you that "usr_times=usr_times++1" doesn't work

    YOu need: "usr_times=usr_times + 1"

  3. #3
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    sweden
    Posts
    646
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Sorry, was a bit confused when I tried to explain what the page does, since I'm working on like 10 pages at the time.
    The page I'm talkig about is checking if the users status is set to 1 or not (if they have been activated).

    It's also setting a couple of Session stuff to be used later on following pages.

    But here is the code that is corrupted.
    (oh, by the way, the ++ thing is working. So I don't need to change that.)

    PHP Code:
    <?php require_once('Connections/connection_code.php'); ?>
    <?php
    session_start
    ();
    $MM_authorizedUsers "1";
    $MM_donotCheckaccess "true";

    // *** Restrict Access To Page: Grant or deny access to this page
    function isAuthorized($strUsers$strGroups$UserName$UserGroup) { 
      
    // For security, start by assuming the visitor is NOT authorized. 
      
    $isValid False

      
    // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
      // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
      
    if (!empty($UserName)) { 
        
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
        // Parse the strings into arrays. 
        
    $arrUsers Explode(","$strUsers); 
        
    $arrGroups Explode(","$strGroups); 
        if (
    in_array($UserName$arrUsers)) { 
          
    $isValid true
        } 
        
    // Or, you may restrict access to only certain users based on their username. 
        
    if (in_array($UserGroup$arrGroups)) { 
          
    $isValid true
        } 
        if ((
    $strUsers == "") && true) { 
          
    $isValid true
        } 
      } 
      return 
    $isValid
    }

    $MM_restrictGoTo "wrong.php";
    if (!((isset(
    $_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers$_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
      
    $MM_qsChar "?";
      
    $MM_referrer $_SERVER['PHP_SELF'];
      if (
    strpos($MM_restrictGoTo"?")) $MM_qsChar "&";
      if (isset(
    $QUERY_STRING) && strlen($QUERY_STRING) > 0
      
    $MM_referrer .= "?" $QUERY_STRING;
      
    $MM_restrictGoTo $MM_restrictGoTo$MM_qsChar "accesscheck=" urlencode($MM_referrer);
      
    header("Location: "$MM_restrictGoTo); 
      exit;
    }
    ?>
    <?php

    $colname_rs_user 
    "1";
    if (isset(
    $_SESSION['MM_Username'])) {
      
    $colname_rs_user = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
    }
    mysql_select_db($database_website_com$website_com);
    $query_rs_user sprintf("SELECT * FROM table_user WHERE username = '%s'"$colname_rs_user);
    $rs_user mysql_query($query_rs_user$website_com) or die(mysql_error());
    $row_rs_user mysql_fetch_assoc($rs_user);
    $totalRows_rs_user mysql_num_rows($rs_user);

    if(
    $row_rs_user['status'] = 1){

            
    // Register some session variables!
            
    session_register('usr_id');
            
    $_SESSION['usr_id'] = $row_rs_user['user_id'];
            
            
    session_register('usrname');
            
    $_SESSION['usrname'] = $row_rs_user['username'];
            
            
    session_register('passwrd');
            
    $_SESSION['passwrd'] = $row_rs_user['password'];
            
            
    session_register('typ');
            
    $_SESSION['typ'] = $row_rs_user['type'];

            
    session_register('state');
            
    $_SESSION['state'] = $row_rs_user['status'];

            
    session_register('updated');
            
    $_SESSION['updated'] = $row_rs_user['updated'];

            
    $usr_id $row_rs_user['user_id'];

            
    mysql_query("UPDATE table_user SET usr_times=usr_times++1, usr_last=now() WHERE user_id='$usr_id'");
            
    //mysql_free_result($rs_user);
            
    header("Location: index_in.php"); /* Redirect browser */
            /* Make sure that code below does not get executed when we redirect. */
            
    exit;

    } else {
            
    //mysql_free_result($rs_user);
            
    header("Location: status_no.php");
            exit;
    }
    ?>
    A lot of code is generated by Dreamweaver (which is what I'm working with here).


Bookmarks

Posting Permissions

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