By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,601 Members | 1,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,601 IT Pros & Developers. It's quick & easy.

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

P: n/a
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=selected 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..
Jun 13 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
ED

"maya" <ma********@yahoo.com> wrote in message
news:44***********************@news.sunsite.dk...
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=selected 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..


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=selected+records+have+been+deleted+et c
not
home.php?msg=selected records have been deleted from the database.
(see: http://uk2.php.net/urlencode )

cheers
ED
Jun 13 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.