943,769 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 1817
  • PHP RSS
Sep 26th, 2008
0

Where _GET[] array is formed?

Expand Post »
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.
Reputation Points: 10
Solved Threads: 2
Light Poster
mohammed2raja is offline Offline
30 posts
since Sep 2008
Sep 26th, 2008
1

Re: Where _GET[] array is formed?

Quote ...
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:
php Syntax (Toggle Plain Text)
  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
php Syntax (Toggle Plain Text)
  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.
Sponsor
Featured Poster
Reputation Points: 410
Solved Threads: 258
Occupation: Genius
cwarn23 is offline Offline
3,004 posts
since Sep 2007
Sep 26th, 2008
0

Re: Where _GET[] array is formed?

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[]?
Reputation Points: 10
Solved Threads: 2
Light Poster
mohammed2raja is offline Offline
30 posts
since Sep 2008
Sep 26th, 2008
0

Re: Where _GET[] array is formed?

use this:
PHP Syntax (Toggle Plain Text)
  1. if(empty($_GET))
  2. {
  3. //code
  4. }
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
Sep 26th, 2008
0

Re: Where _GET[] array is formed?

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:
php Syntax (Toggle Plain Text)
  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
Sponsor
Featured Poster
Reputation Points: 410
Solved Threads: 258
Occupation: Genius
cwarn23 is offline Offline
3,004 posts
since Sep 2007
Sep 26th, 2008
0

Re: Where _GET[] array is formed?

Thank U. I got It.
Reputation Points: 10
Solved Threads: 2
Light Poster
mohammed2raja is offline Offline
30 posts
since Sep 2008
Sep 26th, 2008
0

Re: Where _GET[] array is formed?

I want exactly this code. Thank u
Reputation Points: 10
Solved Threads: 2
Light Poster
mohammed2raja is offline Offline
30 posts
since Sep 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: How to return a php variable, to a html file which can be use in html file as javascr
Next Thread in PHP Forum Timeline: FTP URL Navigation





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC