473,396 Members | 1,849 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

redirect

Hi,

What's wrong with that?

I have a variable

$order_nummer = "C.45";

Then I redirect to

header('Location: xmlorderon.php?order_id=$order_nummer');

but I my location bar I see:

http://localhost/pcGebruik/files/xmlorderon.php?order_id=$order_nummer
thx
Alain
Jul 17 '05 #1
5 3103
Use double quotes instead.
" instead of ' in your header argument.
On Wed, 4 Feb 2004 11:24:53 +0100, "alain dhaene"
<a.******@instruct.be> wrote:
Hi,

What's wrong with that?

I have a variable

$order_nummer = "C.45";

Then I redirect to

header('Location: xmlorderon.php?order_id=$order_nummer');

but I my location bar I see:

http://localhost/pcGebruik/files/xmlorderon.php?order_id=$order_nummer
thx
Alain


Jul 17 '05 #2
alain dhaene wrote:
I have a variable

$order_nummer = "C.45";

Then I redirect to

header('Location: xmlorderon.php?order_id=$order_nummer');

but I my location bar I see:

http://localhost/pcGebruik/files/xmlorderon.php?order_id=$order_nummer


The contents of single quotes are taken literally (with two exceptions).

echo 'the variable a holds $a'; // taken literally
echo 'it\'s a exception'; // the \' is taken as a single '
echo 'the other exception is \\ a single backslash';
So to have your header() do what you want either use double quotes
(which interpolate much more than single quotes) or concatenate the
contents of $order_nummer to the rest of the URL:

header('Location: xmlorderon.php?order_id=' . $order_nummer);

Better yet is to use urlencode() for the $order_nummer:

header('Location: xmlorderon.php?order_id=' . urlencode($order_nummer));
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #3
Pedro Graca <he****@hotpop.com> schrieb:
Better yet is to use urlencode() for the $order_nummer:

header('Location: xmlorderon.php?order_id=' . urlencode($order_nummer));


And even better would be the use of a valid syntax for the location.

header('Location: http://www.example.com/xmlorderon.php?order_id=' .
urlencode($order_nummer));

According to http://www.php.net/manual/en/function.header.php HTTP/1.1
requires an absolute URI as argument to Location: including the scheme,
hostname and absolute path, but some clients accept relative URIs. So
with the short version it might work on some clients and fail on others
and that's not what you want. :-) Use the correct version and it will
run anywhere.

Regards,
Matthias
Jul 17 '05 #4
Matthias Esken wrote:
And even better would be the use of a valid syntax for the location.

header('Location: http://www.example.com/xmlorderon.php?order_id=' .
urlencode($order_nummer));


Right. Thank you for the correction.

The W3C (World Wide Web Consortium) says the same thing about the
Location: header:
http://www.w3.org/Protocols/rfc2616/....html#sec14.30
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #5
Pedro Graca wrote:
Right. Thank you for the correction.


Where it is written "correction", please read "revision and update"
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #6

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

Similar topics

10
by: Bob Garbados | last post by:
forgive my ignorance, as I'm new to php coming from a ms background... If I create a page named redirect.php and it's only content is: <?php header("Location: http://www.google.com"); ?>...
3
by: Paul | last post by:
I'm not getting the results I want when I use Response.Redirct in a ASP page. I enter this line of code in a asp page from domain1.com. Response.Redirect...
7
by: Donna Hawkins | last post by:
I want to use javascript to redirect to a URL which has been passed as a variable (in php). I have searched but cannot find any solution. I think this code is a basic redirect: <script...
1
by: Peter Kirk | last post by:
Hi there I have a program written by another company (it's a "web control" which returns a web-page: can I compare this to a servlet in the Java world?), which they think is causing problems on...
2
by: Mark Dengler | last post by:
Is it possible to do a Response.Redirect to multiple URLs? I have tried the following and it simply ignores the first redirect: Response.Redirect("test.aspx", false);...
3
by: Justin | last post by:
Hi, Im confused here over the usage of Response.Redirect and Server.Transfer. I used frameset for my work, what are the proper usages of the two methods that seems working similar.. The...
6
by: Sam | last post by:
I have some issues with HTTP Headers and I was hoping for some pointers or references to good articles. Here is the problem. I have 6 .aspx pages, each page contains a common .ascx. This ascx...
6
by: Peter Row | last post by:
Hi, I am writing a DLL in VB.NET that implements IHttpHandler.ProcessRequest. This code calls a sub and I need to know if that sub did a response redirect or not. Specifically I need to know...
5
by: venner | last post by:
I'm having an issue with an ASP.NET website after upgrading to ASP.NET 2.0. The website makes use of a central authentication service (CAS) provided at the university I work for. Each page checks...
10
by: Eirik Eldorsen | last post by:
How can I 301 redirect www.example.com/default.aspx to www.example.com without using ISAPI filters?
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
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,...

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.