473,698 Members | 2,250 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using header("Locatio n:...". How to pass over array variable?

Hi there,

I have a php script that does some form input validation. As it verifies
each field if the field has incorrect data, it appends an error message to
an $error array. E.g.

if (an_error = true) {
$errors.="<tr>< td>You have note entered a surname. This is mandatory date
of birth incorrectly.</td></tr>";
}

Previously I had always had the HTML error page code contained within the
same script, but now I am moving it out to make maintenance easier.

When validation completes there is now a statement that says
if ($errors!="") {
header("Locatio n: ./error_page.php" );
}

However, how can I pass the errors array to the error_page. I want to be
able to list each error individually.

Forgive me if this is a silly easy question. I have only been doing PHP for
about a week.
Thanks in advance.

Kind regards

Dave

Jul 17 '05
13 11802
Michael Fesser wrote:
As I was told in this very group some weeks back (by you. :P) a
locationheader needs an absolute URL.

No, it doesn't.


It does.

RFC 2616, section 14.30


And section 5 and the following subsections of RFC3986 deal with the
resolution of relative URIs. However, it was only published in January
2005 but I'm pretty sure all the browsers I have ever used since 1997
have supported relative URI redirection.

It is still probably best to have full URIs though, and it's easy enough
to do using the $_SERVER['HTTP_HOST'] variable in your location string.

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Jul 17 '05 #11
.oO(Chris Hope)
Michael Fesser wrote:
RFC 2616, section 14.30
And section 5 and the following subsections of RFC3986 deal with the
resolution of relative URIs. However, it was only published in January
2005 but I'm pretty sure all the browsers I have ever used since 1997
have supported relative URI redirection.


The HTTP RFC clearly states that the Location URI has to be absolute.
IMHO a conforming user agent doesn't have to be able to resolve relative
URIs if he can expect an absolute one.
It is still probably best to have full URIs though, and it's easy enough
to do using the $_SERVER['HTTP_HOST'] variable in your location string.


Agreed.

Micha
Jul 17 '05 #12
Tim Van Wassenhove wrote:
[Erwin Moller wrote:]
micha wrote:
header("Locatio n: ./error_page.php? NAME=VALUE")


As I was told in this very group some weeks back (by you. :P)
One of us is getting our Michas confused!
a locationheader needs an absolute URL.


Quite true here.
But now we have:
http://www.ietf.org/rfc/rfc3986.txt


But that doesn't change RFC2616, which requires that HTTP
Location headers consist of a single absolute URI. HTTP/1.1
delegates the definition of 'absoluteURI' to RFC2396, now
obsoleted by RFC3986. By looking at Appendix D.2 of the new
RFC, you can see that the 'absoluteURI' rule from RFC2396 is
equivalent to the 'absolute-URI' rule of RFC3986. The only
real difference I spotted between the two is that now the
path component can be empty.

http://www.ietf.org/rfc/rfc2396.txt
http://www.ietf.org/rfc/rfc3986.txt

Mind you, that's all a bit irrelevant. The HTTP/1.1 errata
corrects the definition of Location by allowing a fragment
identifier, and provides a new ABNF rule:

Location = "Location" ":" absoluteURI [ "#" fragment ]

http://skrb.org/ietf/http_errata.htm...tion-fragments

So, to sum up, under the new RFC3986 and by taking into
account the HTTP/1.1 errata, an HTTP Location header
effectively consists of a single *URI*:

URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]

--
Jock
Jul 17 '05 #13
Michael Fesser wrote:

.oO(Anonymous)
Erwin Moller wrote:

As I was told in this very group some weeks back (by you. :P) a
locationheader needs an absolute URL.

No, it doesn't.


It does.

RFC 2616, section 14.30


[readin it up]

Interesting. You are right, according to the RFC it does.

It also works relative, however.
Jul 17 '05 #14

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

Similar topics

2
4438
by: Stijn Goris | last post by:
Hi all, I have a question regarding the header function. I send a browser to a certain page (eg first.php ) wich sends no output to the browser. This page sends the browser to another page (eg second.php) with the header("Location:") function. second.php doesn't either send any output to the browser. The browser is then send to another page also with the header() function. Now my problem: I have to send user and password data...
11
6070
by: Francisco Mendez | last post by:
I get the following message when trying to run my script: "Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/newcustomer.php:23) in /var/www/html/newcustomer.php on line 332" ....newcustomer.php:23 is where my script begins, at line 23. before that line, only comments.
6
2365
by: bissatch | last post by:
Hi, I am trying to use the following function: header("Location: http://www.mysite.co.uk/home/update/index.php"); ....but getting the following error: Warning: Cannot modify header information - headers already sent by (output started at
5
3217
by: Duderino82 | last post by:
I'm working on a very simple peace of php where basically there is a form and 3 buttoms. One refreshed the page, one posts the form, and another one (since this form contains values of a record) deletes the record. The sintax is this one: if ($delete) { header ("Location: $redirect?del=$code&table=$tab"); exit; }
1
2247
by: hemingvej45 | last post by:
Session variables set before a header("Location: whatever") are not being written. And yes, before the header() call, I have session_write_close() but the result is the same. This problem is with PHP 4.3.10 on my hosting providers' server (and obviously I wouldn't like the hassle of changing hosting providers), but it works OK on some other PHP 4 and PHP 5 servers. Is there any workaround?
3
2182
by: thomasg | last post by:
Hi, I am moving some scripts from a UNIX box to a Windows box. A data entry form calls a PHP script the updates the records from the form. After the script completes, The script redirects to anothe page. No headers have been sent, the script just does the database update. This works on the UNIX account: Header( "Location: http://www.new-url.com" ); It does not work on the IIS box.
4
9169
by: andre rodier | last post by:
Hello, I need to display or propose a jpeg image on a web page. When I need to display the image, I use this code : header("Content-Length: $fileSize") ; header("Content-Type: $type") ; header("Content-disposition: inline") ; header("Location: $imageURL"); And when I need to propose the image to save, I use this one :
5
11797
bilibytes
by: bilibytes | last post by:
hi, i am making a website with php OOP. i have a class called session: it has the attribues -logged_in; -user_name; -user_ip; -user_level;
0
8675
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
8604
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9160
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
9029
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
8897
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
6521
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
5860
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();...
1
3050
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
2331
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.