Page 1 of 1
php code
Posted: Fri May 23, 2008 7:05 am
by nitsmooth
Everah | Please use descriptive titles for your posts. "PHP Code" is horribly ambiguous. Thanks.
Could smbdy tell wat this code does
isset($_GET["action"]) and $_GET["action"]=="add"
Re: php code
Posted: Fri May 23, 2008 7:24 am
by mVeliki
Second half of this expression should be grouped with "(" and ")" - just in case,
or use "&&" instead of "and".
Code: Select all
isset($_GET["action"]) and ($_GET["action"]=="add")
This will check is parameter "action" exist in URL and is its value "add", for example:
http://www.mysite.cc/index.php?action=add
Re: php code
Posted: Fri May 23, 2008 10:08 am
by highjo
hi! this code is actually to check if there is a content in a form submit.
i always takes examples to explain things
suppose you have a form (html one) with the method get and the action action.php like this:
Code: Select all
<form name="form1" method="get" action="action.php">
<input type="text" name="name" id="name" >
<input type="submit" value="submit" name="add">
</form>
then on the top of your action.php
you can write this
Code: Select all
if(isset($_GET["name"]) && $_GET["name"]=="add")
{
// then you do what need to be done
}
//generaly people use this rather
if(isset($_GET["name"]) && $_GET["name"] !=" ")
{
// then you do what need to be done
$name = $_GET['name'];
}
are you ok?
Re: php code
Posted: Fri May 23, 2008 12:31 pm
by RobertGonzalez
mVeliki wrote:Second half of this expression should be grouped with "(" and ")" - just in case,
or use "&&" instead of "and".
Code: Select all
isset($_GET["action"]) and ($_GET["action"]=="add")
This will check is parameter "action" exist in URL and is its value "add", for example:
http://www.mysite.cc/index.php?action=add
Wrapping the parens in not at all required.
What the code is doing is checking to see if a querystring parameter of the name 'action' was passed and, if it was, if it had a value of 'add'.