when a value passed in form or q'string is empty..

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • maya

    when a value passed in form or q'string is empty..

    hello, I am trying to figure out how to deal with when not all elements
    in a submitted form are filled out or when page expects a query string
    and doesn't get one.. I tried the two conditionals below, but still got
    errors:

    $param= $_GET['msg'];

    /*
    if ($param != "") {
    echo $param;
    }
    */

    if (isset($param)) {
    echo $param;
    }


    query string is:

    home.php?msg=se lected records have been deleted from the database.

    (referrer pg is not always pg sending query string.. so need to deal
    w/when no query string is passed..)

    thank you very much..


  • ED

    #2
    Re: when a value passed in form or q'string is empty..


    "maya" <maya778899@yah oo.com> wrote in message
    news:448f0765$0 $15795$14726298 @news.sunsite.d k...[color=blue]
    > hello, I am trying to figure out how to deal with when not all elements in
    > a submitted form are filled out or when page expects a query string and
    > doesn't get one.. I tried the two conditionals below, but still got
    > errors:
    >
    > $param= $_GET['msg'];
    >
    > /*
    > if ($param != "") {
    > echo $param;
    > }
    > */
    >
    > if (isset($param)) {
    > echo $param;
    > }
    >
    >
    > query string is:
    >
    > home.php?msg=se lected records have been deleted from the database.
    >
    > (referrer pg is not always pg sending query string.. so need to deal
    > w/when no query string is passed..)
    >
    > thank you very much..
    >
    >[/color]

    try:
    if (isset($_GET['msg']) && !empty($_GET['msg'])) {
    $param = $_GET['msg'];
    //do whatever
    }
    As an aside you should also be urlencoding the query string values:
    home.php?msg=se lected+records+ have+been+delet ed+etc
    not
    home.php?msg=se lected records have been deleted from the database.
    (see: http://uk2.php.net/urlencode )

    cheers
    ED


    Comment

    Working...