Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

request isdefined

Status
Not open for further replies.

iamsw00sh

Programmer
May 21, 2003
92
RO
The question is about :

$username = $_REQUEST['username'];

the thing is, that in this page.php, sometimes there is a "username" parameter
and sometimes there is no parameter

is there something what I can use to see if the $_REQUEST['username'] is "defined in this page?"

ASP handles this very flexible ... if there was no 'username' parameter sent, then $_REQUEST['username'] = ""
ColdFusion has something like "if isdefined $_REQUEST['username'] then"

what can I do here ?

thank you

--
If I would be such a good coder as I like coding ... I would be the Best
 
You can try to use the isset() function like so

Code:
if(isset($_REQUEST['username'])){
     then do my thing
}

or you can have it do something when it is not set
Code:
if(!isset($_REQUEST['username'])){
     then do my thing
}

JRSofty
 
can I use the same thing for Session variables too ?

--
If I would be such a good coder as I like coding ... I would be the Best
 
I know you can also do:
Code:
if(!($foo)) {
  echo "wtf?";
 }
else {
  echo $foo;
}

Dont know the performance-issues, etc. by using this though!

Olav Alexander Mjelde
Admin & Webmaster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top