Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

php and query string

  • 09-04-2008 1:40pm
    #1
    Registered Users, Registered Users 2 Posts: 26,584 ✭✭✭✭


    hey guys, totally new to php but coming from perl.

    i have a logout.php that basically unsets all $_SESSION variables that i've set and redirects to an index.php with a query string like so index.php?message=logged out successfully.

    now back in the index.php page i'd like to display a message to the user saying that they have just logged out.

    since i'm coming from perl i'm mad into regular expressions and could easily do a regex on $_SERVER but i fear there may be a much more easier way of getting the message variable from the query string. $_GET doesn't work as it hasn't been sent by a html form i presume.

    i know php is great for these global arrays eg $_SERVER and $_SESSION but is there one that holds all the variables from the query string?


Comments

  • Registered Users, Registered Users 2 Posts: 6,571 ✭✭✭daymobrew


    Cremo wrote:
    $_GET doesn't work as it hasn't been sent by a html form i presume.
    It will work for the example url you provided. Maybe use 'index.php?message=loggedout' and then your index.php will have something like:
    [PHP]if ( defined( $_GET == 'loggedout' ) ) {
    echo '<p>You have been logged out.</p>';
    }[/PHP]


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    Google for the php $_POST and $_GET variables and all shall be revealed.


  • Closed Accounts Posts: 8,478 ✭✭✭GoneShootin


    Cremo wrote: »
    $_GET doesn't work as it hasn't been sent by a html form i presume.


    $_GET will work fine in this case as it doesn't require any submit to a form for it to be displayed at the target page. $_GET will check the URL and handle the paramaters after the "index.php?" appropriately.

    As $_GET and $_POST are arrays, to debug you can always use something like:

    print_r($_GET);

    This will print the contents of a $_GET array and help you debug...

    Show us your code and it will make it easier to sort it out.


  • Registered Users, Registered Users 2 Posts: 26,584 ✭✭✭✭Creamy Goodness


    oops i made a bad noob mistake.

    i had the redirect as index.php?msg=loggedout and was using $_GET in the index.php.

    :pac:


  • Closed Accounts Posts: 8,478 ✭✭✭GoneShootin


    It happens to everyone :) I've wasted too much time on different occasions trying to troubleshoot what seemed a complicated problems only to find that it was something as trivial as an incorrectly spelled variable.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 6,571 ✭✭✭daymobrew


    only to find that it was something as trivial as an incorrectly spelled variable.
    The lack of variable declaration and verification is one of the things I feel is lacking in PHP. In perl 'use strict' and 'use warnings' go a long way to preventing such trivial errors.

    Is there anything similar in PHP?


  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    daymobrew wrote: »
    Is there anything similar in PHP?
    Yep

    http://us3.php.net/error_reporting


  • Registered Users, Registered Users 2 Posts: 26,584 ✭✭✭✭Creamy Goodness


    daymobrew wrote: »
    The lack of variable declaration and verification is one of the things I feel is lacking in PHP. In perl 'use strict' and 'use warnings' go a long way to preventing such trivial errors.

    Is there anything similar in PHP?

    aye strict and warnings have save me - no scratch that, my employer - many hours :D
    Webmonkey wrote: »


    cool handy to know.


Advertisement