Where _GET[] array is formed?

Thread Solved

Join Date: Sep 2008
Posts: 25
Reputation: mohammed2raja is an unknown quantity at this point 
Solved Threads: 1
mohammed2raja mohammed2raja is offline Offline
Light Poster

Where _GET[] array is formed?

 
0
  #1
Sep 26th, 2008
echo "<meta http-equiv=Refresh content=0;url=login.php?nflag=".$nflag.">";

Here i pass PHP variable nflag.
Can any body tell me where this variable(nflag) is store. So when i use
the statement ;

$nflag=$_GET['nflag'];

and get that value. Where the value of 'nflag is stored', ans from where _GET[] array is formed. What are the default value of _GET[] array? Please any body help me.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,476
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 136
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

Re: Where _GET[] array is formed?

 
1
  #2
Sep 26th, 2008
So the line in the middle of the example above is basically telling the server to 'get' the variable 'nflag' from the url bar and to echo/display it.
From: http://www.daniweb.com/forums/thread147753.html
You may want to check the reply I made on your previous post.
The array $_GET[] basically just tells the server to get a variable from the url bar and the name of that variable goes between the two brackets. So say for example the address is as follows:
http://www.daniwebs.com/forums/newreply.php?do=postreply&t=14773
Then to get the variable 'do' you would use the following code to print/echo/display it to the browser:
  1. <? echo $_GET['do']; ?>
  2. Above produces below
  3. postreply
or if you wanted to get the other variable in that address you would use
  1. <? echo $_GET['t']; ?>
  2. above produces below:
  3. 14773
So the $_GET array and any other array beginning with $_ (dollar sign then underscore) is a inbuilt function.
As for the default value, there is no default value as it only holds the values that are in the url bar.
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 25
Reputation: mohammed2raja is an unknown quantity at this point 
Solved Threads: 1
mohammed2raja mohammed2raja is offline Offline
Light Poster

Re: Where _GET[] array is formed?

 
0
  #3
Sep 26th, 2008
Thanks cwarn23
But I hv a doubt. How can i check whether there are any value in url bar or empty. I mean how can i check there is a value in url or not. If there only address in url bar, then what is the value of _GET[]?
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,073
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: Where _GET[] array is formed?

 
0
  #4
Sep 26th, 2008
use this:
  1. if(empty($_GET))
  2. {
  3. //code
  4. }
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,476
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 136
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

Re: Where _GET[] array is formed?

 
0
  #5
Sep 26th, 2008
Well $_GET[] should always have quotation marks between the brackets and numbers/letters/characters between the quotation marks. So $_GET[] on its own isn't a valid command. You need something like $_GET['a'] or $_GET['myvariable'] and if it does not exist in the url bar then it will return a string with 0 letters 0 numbers and 0 characters. So basically a $_GET statement which has letters between the brackets and quotation marks but those letters/variable does not exist in the url bar will return the below string if you remove the quotation marks:
"" - as you can see there is nothing between those quotation marks so you will just receive a blank string if it does not exist in the url bar.

So just a reminder, you always need something between those brackets (more than just quotation marks).

Edit:
I just saw more of what you are asking for and to check if there is nothing there i prefer to use the preg replace function just like follows:
  1. $urlvars=preg_replace('/(.*)?(.*)/i',$2,$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);
  2. if ($urlvars='')
  3. {
  4. //code in here
  5. }
The preg replace should be something along those lines.
Last edited by cwarn23; Sep 26th, 2008 at 7:24 am. Reason: Added info
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 25
Reputation: mohammed2raja is an unknown quantity at this point 
Solved Threads: 1
mohammed2raja mohammed2raja is offline Offline
Light Poster

Re: Where _GET[] array is formed?

 
0
  #6
Sep 26th, 2008
Thank U. I got It.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 25
Reputation: mohammed2raja is an unknown quantity at this point 
Solved Threads: 1
mohammed2raja mohammed2raja is offline Offline
Light Poster

Re: Where _GET[] array is formed?

 
0
  #7
Sep 26th, 2008
I want exactly this code. Thank u
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC