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"
php code
Moderator: General Moderators
Re: php code
Second half of this expression should be grouped with "(" and ")" - just in case,
or use "&&" instead of "and".
This will check is parameter "action" exist in URL and is its value "add", for example:
http://www.mysite.cc/index.php?action=add
or use "&&" instead of "and".
Code: Select all
isset($_GET["action"]) and ($_GET["action"]=="add")http://www.mysite.cc/index.php?action=add
Re: php code
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:
then on the top of your action.php
you can write this
are you ok?
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>
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'];
}
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: php code
Wrapping the parens in not at all required.mVeliki wrote:Second half of this expression should be grouped with "(" and ")" - just in case,
or use "&&" instead of "and".This will check is parameter "action" exist in URL and is its value "add", for example:Code: Select all
isset($_GET["action"]) and ($_GET["action"]=="add")
http://www.mysite.cc/index.php?action=add
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'.