473,738 Members | 11,146 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

$HTTP_SERVER_VA RS['SCRIPT_FILENAM E'] - getting all GET vars too?

Hi,

I am using $HTTP_SERVER_VA RS['SCRIPT_FILENAM E'] to get the name of the
current web page. How do I also get the GET variables using PHP as a
complete string. For example:

'?first=12&seco nd=value&third= 2.99'

As I dont know what the variables may I cant simply use $_GET. Ideally
something like FOR EACH $_GET to generate the GET part of the url. Any
ideas? Cheers

Burnsy
Jul 17 '05 #1
3 3939
On 5 Dec 2004 07:25:00 -0800, bi******@yahoo. co.uk (mr_burns) wrote:
I am using $HTTP_SERVER_VA RS['SCRIPT_FILENAM E']
$_SERVER would be preferred, but it's the same info.
to get the name of the
current web page. How do I also get the GET variables using PHP as a
complete string. For example:

'?first=12&sec ond=value&third =2.99'
Look at $_SERVER['QUERY_STRING']

phpinfo() is useful for dumping out all the superglobals, or you could just
var_dump($_SERV ER) etc.; you can then see which ones may have the information
you need.
As I dont know what the variables may I cant simply use $_GET. Ideally
something like FOR EACH $_GET to generate the GET part of the url.


Well, yes exactly that.

foreach ($_GET as $key => $val)

... same as any associative array. There could be arrays in there though which
are treated a bit differently. It's all available in $_SERVER['QUERY_STRING'],
but looping through $_GET may be useful if:

(a) you want to modify/add/remove some of the values, but keep the rest
(b) you want to change the separator, e.g. from & to ;

--
Andy Hassall / <an**@andyh.co. uk> / <http://www.andyh.co.uk >
<http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2
.oO(Andy Hassall)
On 5 Dec 2004 07:25:00 -0800, bi******@yahoo. co.uk (mr_burns) wrote:
I am using $HTTP_SERVER_VA RS['SCRIPT_FILENAM E']
$_SERVER would be preferred, but it's the same info.


Same info, but not the same scope. $_SERVER is superglobal, the old
$HTTP_* arrays are not.
but looping through $_GET may be useful if:

(a) you want to modify/add/remove some of the values, but keep the rest
(b) you want to change the separator, e.g. from & to ;


This can also be done with modifying 'arg_separator. input' if possible.

Micha
Jul 17 '05 #3
On Mon, 06 Dec 2004 14:13:29 +0100, Michael Fesser <ne*****@gmx.ne t> wrote:
.oO(Andy Hassall)
On 5 Dec 2004 07:25:00 -0800, bi******@yahoo. co.uk (mr_burns) wrote:
I am using $HTTP_SERVER_VA RS['SCRIPT_FILENAM E']


$_SERVER would be preferred, but it's the same info.


Same info, but not the same scope. $_SERVER is superglobal, the old
$HTTP_* arrays are not.


True.
but looping through $_GET may be useful if:

(a) you want to modify/add/remove some of the values, but keep the rest
(b) you want to change the separator, e.g. from & to ;


This can also be done with modifying 'arg_separator. input' if possible.


Well, having that set might be _why_ you'd want to rewrite URLs to use ';'
instead of '&' (which browsers tend to send), rather than _how_. I tend to have
arg_separator.i nput set to '&;', and write out URLs separated with ';' mostly
because it's easier than escaping & into &amp; all over the place.
arg_separator.o utput handles anything where PHP constructs URLs, but I think
that's mostly just the form rewriting it does for cookie-less sessions.

--
Andy Hassall / <an**@andyh.co. uk> / <http://www.andyh.co.uk >
<http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2921
by: lawrence | last post by:
I've this function, which is the method of a class. I'm posting the constructor of the class down below. For some reason, when I fill out a form and hit submit, I'm not getting any values. Can someone tell me why? function getVar($var="password") { // 05-08-03 - the important thing about this function is it reverses
4
1762
by: Preston Crawford | last post by:
I'm working on a site that's being developed on Apache/Linux and going to be hosted on IIS/Windows. Anyone know of a site with good tips on possible pitfalls, things to look for. Typical things I'll be looking to do that I can see tripping me up include file upload, email, etc. I'll be googling until then, but I thought I'd ask as well. Preston
3
1538
by: none | last post by:
Hi all, now if I've understood the code below correctly, if I add the line; $session_dean_id = $hResult('dean_id'); At the bottom I will create a new variable named '$session_dean_id' which will have the value grabbed from the table 'iUser' from the 'dean_id' column. Am i right or way off? Many thanks
0
2768
by: |-|erc | last post by:
Hi! Small challenge for you. The index.php uses this file and calls layout(). Take a look at www.chatty.net this file draws the chat login box on the right. I traced the CHAT button it submits and goes to the index file again, I can't figure out how it opens the chatroom. I want to get it to skip the login box and go straight to the room, with user name "guest" or "" or whatever but I'll add a field to type the name in the chat room....
21
2380
by: Thomas Mlynarczyk | last post by:
Hello, My provider has set register_globals = On and I can't change the php.ini file. Is there a way to unset all the imported get/post etc. variables at the beginning of my script? Thomas
1
1644
by: Bob Bedford | last post by:
Hi, I've this code in my form: <?php ini_set('use_trans_sid',1); session_cache_limiter('private, must-revalidate'); if(!session_is_registered("UID")){ session_start(); $UserID = 0; if (isset($_SESSION) and $_SESSION != "")
2
1524
by: Dogstar | last post by:
I am trying to add a 'feedback' button on every page on a website. I want to add the button to the page footer which is accessed on each page using the include function. I want the feedback button to open a email form with a hidden option to include the url that the user has come from. I have tried $url="http://".$_SERVER.$_SERVER; and $url=$HTTP_SERVER_VARS; both of which give me the footer url rather than the actual page which the...
3
2757
Jezternz
by: Jezternz | last post by:
Easy to get the external ip adress, using the $SERVER var, but I want the local ip. My situation isnt normal by the way. Basicly im building simple intranet ( i want to run this on a local area network (will be hundreds of people) not on the web, so for logins im gonna be using local ip's, is there any way I can get them easily? $HTTP_SERVER_VARS <- people have said this would work.. but would it actually work in a lan invroment, im not so...
13
4037
matheussousuke
by: matheussousuke | last post by:
Does anyone use oscommerce in there;; In modules and in another partas of the shop I'm having the followin troubleÇ -------------------------- Autoriza��o de pagamento_br_utilizando o servi�o _br__a href=https://pagseguro.uol.com.br/defaultbr.aspx?ind=2554718 target=_blank__b_PagSeguro_/b__/a_._br_Vers�o: 2.0 by _a href="https://pagseguro.uol.com.br/defaultbr.aspx?ind=2554718" target=_blank__u__i_Módulo para loja...
0
9476
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9335
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9208
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8210
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6751
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6053
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.