SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Evangelist dscriptor's Avatar
    Join Date
    Oct 2005
    Location
    in front of my computer
    Posts
    571
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question passing session var from one page to another

    to all the Gurus in PHP,
    please help...

    im stack in my problem passing variable to another page....

    ok..i have this bill.php...
    PHP Code:
    include ("conf.inc.php");
    session_start();
    if (!empty(
    $HTTP_POST_VARS)) {
      
    $mode $HTTP_POST_VARS[mode];
    }

    if (!isset(
    $mode)) {
     if (!
    $auth->checkloginhere()) {
        
    bill_login();
    }
     else {
       
    bill_index();
       }

    } else {
            switch (
    $mode) {
            case 
    "login":
                 
    VerifyLogin($HTTP_POST_VARS[uname],$HTTP_POST_VARS[passwd]);
                break;
            case 
    "logout":
              
    $_SESSION['username'] = '';
              
    //$auth->logout_regusers();
              
    $auth->logout();
              
    bill_login();
            break;
            
            case 
    "adminuser"
                 
    admin_users();
                break;
                
             case 
    "wapdownloads" :     
             
    //$smarty->assign("username",$_SESSION['username']);
                
    wapdownloads($sortq,$_SESSION['username']);
                break;
            
            case 
    "home" :     
                 
    bill_index();
                break;

            
              default :
               
    bill_index();
                break;
           }
    }

    function 
    bill_index() {
     Global 
    $smarty$db;


      if (
    $_SESSION['username']!='') {
         
    $smarty->assign("username",$_SESSION['username']);
      }
      
    $smarty->assign("username",$_SESSION['username']);
      
      
    $smarty->display("bills/main.html");
    }


    function 
    bill_login() {
     GLOBAL 
    $smarty
         
        
    $smarty->display('bills/login.html');
        return 
    true;

    }

    function 
    VerifyLogin($uname,$passwd) {
      Global 
    $smarty,$auth;
      if (!
    $auth->login($uname,$passwd)) { 
              
    $smarty->assign("alert_msg","<script>alert(\"Invalid Login, try again...\")</script>");
            
    $smarty->display('bills/login.html');
      } else {
             
    $smarty->assign("username",$_SESSION['username']);
             
    bill_index();
    }
    }


    //here is where the problem is....the session variable is not being passed...
    function wapdownloads($sortq) {
     Global 
    $smarty$db

    if (
    $_SESSION['username']!="") {

            
    bill_login();
            }else{
     
    $smarty->assign("username",$_SESSION['username']);
            
      
    $smarty->assign("log","<div id=\"teaser\"><h2>User : ".$_SESSION['username']."</h2><a href='bill.php?mode=logout'>Log-out</a></div>");

    //some code here...................
     
    $smarty->display("bills/wapdownloads.html");
      return 
    true;
    }

    PHP Code:
    function checkloginhere() { 
           global 
    $HTTP_COOKIE_VARS
             
    $secret_word 'mmxthebest'
               
    $cookie $_COOKIE['mysite']; 
               
    $split explode(":"$cookie); 
               
    $uname $split[0]; 
               
    $hash $split[1]; 
               
    $hash2 md5($secret_word $uname); 
             
    $_SESSION['username'] = $uname;
             
               if(
    $hash2 == $hash){
            
                return 
    1
            } else { 
                return 
    0
            } 
        } 
    //end checkLogin() 
    the problem is, when i click in the home page the link WAP DOWNLOADS to have a url bill.php?mode=wapdownloads...the session is not being passed....


    please help me here.....
    Last edited by dscriptor; Feb 17, 2006 at 01:11.
    happy is the man that finds wisdom....wisdom in {PHP}.


  2. #2
    SitePoint Evangelist dscriptor's Avatar
    Join Date
    Oct 2005
    Location
    in front of my computer
    Posts
    571
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what i need to do is the user can't go to bill.php?mode=wapdownloads, if he did not logged in first...i am right about this thing..cheking the $_SESSION?....
    please help....

    thanks!
    happy is the man that finds wisdom....wisdom in {PHP}.


  3. #3
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    //session_start(); 
    to
    PHP Code:
    session_start(); 
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  4. #4
    SitePoint Evangelist dscriptor's Avatar
    Join Date
    Oct 2005
    Location
    in front of my computer
    Posts
    571
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    session_start();
    i already did that....but still...there's a problem..
    happy is the man that finds wisdom....wisdom in {PHP}.


  5. #5
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    And the Problem is? (You know you can edit your previous post.)
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  6. #6
    SitePoint Evangelist dscriptor's Avatar
    Join Date
    Oct 2005
    Location
    in front of my computer
    Posts
    571
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the session variable is not passed when it is calling the function
    PHP Code:
    function wapdownloads($sortq
    happy is the man that finds wisdom....wisdom in {PHP}.


  7. #7
    SitePoint Addict
    Join Date
    Nov 2005
    Posts
    241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't you need a } right after
    PHP Code:
    //some code here...................
    $smarty->display("bills/wapdownloads.html");
      return 
    true;

    I don't see where the function is closed.

  8. #8
    SitePoint Evangelist dscriptor's Avatar
    Join Date
    Oct 2005
    Location
    in front of my computer
    Posts
    571
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for post..

    i already edited it...but the problem is not in there...
    happy is the man that finds wisdom....wisdom in {PHP}.


  9. #9
    SitePoint Addict
    Join Date
    Nov 2005
    Posts
    241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dscriptor
    thanks for post..

    i already edited it...but the problem is not in there...
    Sorry, can't help you then.

  10. #10
    SitePoint Evangelist dscriptor's Avatar
    Join Date
    Oct 2005
    Location
    in front of my computer
    Posts
    571
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anyone can help me here....?
    happy is the man that finds wisdom....wisdom in {PHP}.


  11. #11
    SitePoint Zealot WebPharaon's Avatar
    Join Date
    Feb 2006
    Posts
    141
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Seems you need to do some debugging.

    Are any other SESSION variables in place? You can see by doing the

    var_dump($_SESSION);

    If your session is empty at all, it means you have troubles with session initialization, otherwise - somewhere else.
    Sergey Neskhodovskiy
    www.WebProGuide.com
    SEO Articles, news, software reviews,
    resources, experts' bios and more!


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
  •