SitePoint Sponsor

User Tag List

Page 2 of 3 FirstFirst 123 LastLast
Results 26 to 50 of 73

Thread: Sessions

  1. #26
    SitePoint Wizard rctneil's Avatar
    Join Date
    Jun 2005
    Posts
    1,890
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I wantt o make it work properly with error reporting maxed but just cannot understand how to do it? If i post a template of what i need to do could you write a small bit of code whch will allow it to work with error reporting maxed?

  2. #27
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    we showed you how to check if a variable is exists before you use it.

    you have some other issue and you have not shown us any sample code which demonstrates your issue, so we cannot help you.

  3. #28
    SitePoint Wizard rctneil's Avatar
    Join Date
    Jun 2005
    Posts
    1,890
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Basically, this is what i want:

    Code:
    if action = '' then
              if loggedin = 0
                        Default Page
              else
                        Normal Page when logged in
    if action = 'login' then
              if loggedin = 1
                        Already Logged In Message
              else
                        Log in Form
    if action = 'register' then
              if loggedin = 1
                        Already logged in and registered message
              else
                        Registration Form
    Thats the basic jist of it.

    Remember though
    - action is a $_GET variable and can either be '' , 'login' or 'register'
    - loggedin is a $_SESSION variable and can either be 1 or 0

    Thankyou

    Neil

  4. #29
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    where is ur actual code, which u r using

  5. #30
    SitePoint Wizard rctneil's Avatar
    Join Date
    Jun 2005
    Posts
    1,890
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I got so confused with it so i gave that code up. Coudl someone just code a quick page which matches the above template i wrote? I would really apreciate it

  6. #31
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    is this wht u r looking for ?

    PHP Code:
    if ($_POST['action'] == "")
    {
        if (
    $_SESSION['loggedin'] == 0)
        {
            
    header("Location: Defaultpage.php"); 
        }
        else
        {
            
    header("Location: Normal Page when logged in.php"); 
        }           
    }

    if (
    $_POST['action'] == "login" )
    {
        if (
    $_SESSION['loggedin'] == 1)
        {
            echo 
    "Already Logged In Message";
        }
        else
        {
            echo 
    "Log in Form"
        
    }
    }

    if (
    $_POST['action'] == "register" )
    {
        if (
    $_SESSION['loggedin'] == 1)
        {
            echo 
    "Already logged in and registered message";
        }
        else
        {
            echo 
    "Registration Form";
        }


  7. #32
    SitePoint Wizard rctneil's Avatar
    Join Date
    Jun 2005
    Posts
    1,890
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thats excellent but it will do exactly what i was saying before, If i view that page with error reporting to maximum, i will get loads of errors saying suhc and such a variable is undefined, like action and logged in. I wan to be able to use high error reporting but not have those errors. also action should be a $_GET variable not a post one.

  8. #33
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use GET instead of POST, define all variable bfore u use them..

  9. #34
    SitePoint Wizard rctneil's Avatar
    Join Date
    Jun 2005
    Posts
    1,890
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but if at the top of the page i write something like:

    $_SESSION['loggedin'] = 0;

    to define the variable, if a user logs in and the loggedin session changes to 1 and goes back than won't the session varaible be returned to 0? as that is what is written at the top of the page. It's this problem which i am trying to solve along with the one that says that action and logged in are undefined. How can they be defined without overwriting whats in them when a user comes back to the page with a different value set to them?

    Thanks

    Neil

  10. #35
    SitePoint Zealot
    Join Date
    Dec 2006
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi, i also got a question on session which wish to get you guys guidance...

    can i do it like this?

    Code:
    <?php
    session_start();
    
    if (isset($_SESSION['login'])) {
    
        echo "EDIT BUTTON HERE";
    }
    else
    {
        echo "OTHER INFO FOR PUBLIC";
        }
    } 
    ?>

  11. #36
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    var $_SESSION['loggedin']; 
    instead of $_SESSION['loggedin'] = 0;

  12. #37
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey kaylie why dont u use new thread for ur query........
    bye the way the way u r writing the code is look good to me

  13. #38
    SitePoint Zealot
    Join Date
    Dec 2006
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by simplecode View Post
    hey kaylie why dont u use new thread for ur query........
    bye the way the way u r writing the code is look good to me
    simplecode,

    thanks for your reply!!!

    hehe... i post it here cause i felt this is just a small question which i wish to make it clear for my own.

    by the way,if i wanna do this:

    Code:
    <?php
    session_start();
    
    if (isset($_SESSION['login'])) {
    
        echo "EDIT BUTTON HERE";
        echo "OTHER INFO FOR PUBLIC";
    }
    else
    {
        echo "OTHER INFO FOR PUBLIC";
        }
    } 
    ?>

    can i make it in this way?
    Code:
    <?php
    session_start();
    
    if (isset($_SESSION['login'])) {
    
        echo "EDIT BUTTON HERE";
    }
        echo "OTHER INFO FOR PUBLIC";
    ?>
    where it will check whether user login, if yes display the edit button then continue by other info for public. Else it just display the public info???

  14. #39
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  15. #40
    SitePoint Zealot
    Join Date
    Dec 2006
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by simplecode View Post
    thanks for sharing the link again!!!

  16. #41
    SitePoint Wizard rctneil's Avatar
    Join Date
    Jun 2005
    Posts
    1,890
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, Simplecode:

    Whats the code you posted do?

    ie;
    var $_SESSION['loggedin'];
    Thanks

    Neil

  17. #42
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    define the variable

    have u tried it , is that sloving ur purpose

  18. #43

  19. #44
    SitePoint Wizard rctneil's Avatar
    Join Date
    Jun 2005
    Posts
    1,890
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, so thats for defining the session, what about the action, because if i do if ($_GET['action'] == ' register'); or whatever tehn i will get an undefined variable for that?

  20. #45
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have a look at PHP manual once. Try to find the logic what we are writing here else u’ll never come to know wither we are providing Wright or wrong information to u.

    var $_GET['action'];
    var $_POST['action']

  21. #46
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is all r warning or errors.......
    http://us3.php.net/error-reporting

  22. #47
    SitePoint Wizard rctneil's Avatar
    Join Date
    Jun 2005
    Posts
    1,890
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,
    I put this on the page:

    var $_SESSION['loggedin'];

    and I get an unexpected T_VAR error:

    Parse error: parse error, unexpected T_VAR in C:\Documents and Settings\Neil\My Documents\www\template atm\membership.php on line 23

    ?

    Thanks

    Neil

  23. #48
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    dont do that try to switch off error reporting for that page and try again

  24. #49
    SitePoint Wizard rctneil's Avatar
    Join Date
    Jun 2005
    Posts
    1,890
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Curently, error reporting IS ALREADY switched off.

  25. #50
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    dont use var

    whts the err , try to print the err for us to understand the cause
    thanks


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
  •