473,698 Members | 2,261 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 3934
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
2919
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
1759
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
1537
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
2762
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
2373
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
1640
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
1519
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
2755
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
4035
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
8680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9169
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
9030
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...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6528
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
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3052
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
2
2335
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
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.