473,383 Members | 1,733 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,383 software developers and data experts.

redirection question

Perhaps this is not the best design right now in my php script, but I've
just started with php after a long break.

The thing is that I enter a page called foo1.php, this script do some
calculations and should then send directly send the user to a page called
foo2.php together with the variables $bar and $bar2.

On the page foo1.php there will be no input or any clicking required by the
user. Just as soon as the values are calculated, it should continue.
How can I achieve this?
Jan 30 '07 #1
18 1283
On Jan 30, 3:09 pm, Gunnar G <deb...@comhem.sewrote:
Perhaps this is not the best design right now in my php script, but I've
just started with php after a long break.

The thing is that I enter a page called foo1.php, this script do some
calculations and should then send directly send the user to a page called
foo2.php together with the variables $bar and $bar2.

On the page foo1.php there will be no input or any clicking required by the
user. Just as soon as the values are calculated, it should continue.
How can I achieve this?

If the data is not sensitive, you can simply use the header() function
to redirect to the appropriate page passing the variables as
parameters in the URI.

i.e.
header('Location: http://site.com/somepage.php?foo=$foo&bar=$bar");

Otherwise, if you need to hide the parameters, or do not want the page
to be bookmarked you can set the parameters in the session before
redirecting and omit them from the URI.

see:
http://php.net/header
for more info.

Hope that helps,
Carl.

Jan 30 '07 #2
<comp.lang.php>
<Gunnar G>
<Tue, 30 Jan 2007 23:09:59 GMT>
<bf*******************@newsb.telia.net>
Perhaps this is not the best design right now in my php script, but I've
just started with php after a long break.

The thing is that I enter a page called foo1.php, this script do some
calculations and should then send directly send the user to a page called
foo2.php together with the variables $bar and $bar2.

On the page foo1.php there will be no input or any clicking required by the
user. Just as soon as the values are calculated, it should continue.
How can I achieve this?
Is there any good valid reason why you want to redirect to foo2.php ? .

Why not just do the calculations in foo1.php and then display the
results underneath in foo1.php when they are done .
--
www.phptakeaway.co.uk
(work in progress)
Jan 31 '07 #3
On Jan 30, 7:10 pm, Krustov <m...@privacy.netwrote:
<comp.lang.php>
<Gunnar G>
<Tue, 30 Jan 2007 23:09:59 GMT>
<bfQvh.30769$E02.12...@newsb.telia.net>
Perhaps this is not the best design right now in my php script, but I've
just started with php after a long break.
The thing is that I enter a page called foo1.php, this script do some
calculations and should then send directly send the user to a page called
foo2.php together with the variables $bar and $bar2.
On the page foo1.php there will be no input or any clicking required by the
user. Just as soon as the values are calculated, it should continue.
How can I achieve this?

Is there any good valid reason why you want to redirect to foo2.php ? .

Why not just do the calculations in foo1.php and then display the
results underneath in foo1.php when they are done .

--www.phptakeaway.co.uk
(work in progress)
He's probably setting a cookie, which won't be read until a new page
is loaded.
Ya, header("Location: foo2.php"); is what you want.

Jan 31 '07 #4
On Jan 30, 7:44 pm, "GAMEchief" <SegaDra...@gmail.comwrote:
On Jan 30, 7:10 pm, Krustov <m...@privacy.netwrote:
<comp.lang.php>
<Gunnar G>
<Tue, 30 Jan 2007 23:09:59 GMT>
<bfQvh.30769$E02.12...@newsb.telia.net>
Perhaps this is not the best design right now in my php script, but I've
just started with php after a long break.
The thing is that I enter a page called foo1.php, this script do some
calculations and should then send directly send the user to a page called
foo2.php together with the variables $bar and $bar2.
On the page foo1.php there will be no input or any clicking required by the
user. Just as soon as the values are calculated, it should continue.
How can I achieve this?
Is there any good valid reason why you want to redirect to foo2.php ? .
Why not just do the calculations in foo1.php and then display the
results underneath in foo1.php when they are done .
--www.phptakeaway.co.uk
(work in progress)

He's probably setting a cookie, which won't be read until a new page
is loaded.
Ya, header("Location: foo2.php"); is what you want.
Heres an all purposes function. You will run into an issue with
headers if you use any printing before you send the header information
(same with cookies and the session too), this function will send the
request as a JS redirect if the headers have already been sent.

function Redirect($location = "")
{
if (headers_sent())
{
if (!$location)
print '<script language="javascript" type="text/javascript"
>window.history.go(-1)</script>';
else
print '<script language="javascript" type="text/javascript"
>window.location = '.$location.'</script>';
}
else
{
if(!$location)
header("Location: " . $_SERVER["PHP_SELF"];);
else
header("Location: " . $location;);
}
}

Jan 31 '07 #5
..oO(bo*********@gmail.com)
>Heres an all purposes function. You will run into an issue with
headers if you use any printing before you send the header information
(same with cookies and the session too), this function will send the
request as a JS redirect if the headers have already been sent.
How ugly. The "headers already sent" problem can easily be solved
without using unreliable client-side scripting, either be thinking over
the structure of the code or by using output buffering.

Additionally a Location header requires an absolute URL.

Micha
Jan 31 '07 #6
Michael Fesser wrote:
.oO(bo*********@gmail.com)
>>Heres an all purposes function. You will run into an issue with
headers if you use any printing before you send the header information
(same with cookies and the session too), this function will send the
request as a JS redirect if the headers have already been sent.

How ugly. The "headers already sent" problem can easily be solved
without using unreliable client-side scripting, either be thinking over
the structure of the code or by using output buffering.
Totally true: ugly solution.
And besides that, not all clients have JS enabled.
>
Additionally a Location header requires an absolute URL.
Erm...
I think that requirement was dropped some time ago.
And all browsers I have ever seen support the relative URL.
Not tested on Lynx 0.8 beta. ;-)

Regards,
Erwin Moller

>
Micha
Jan 31 '07 #7
..oO(Erwin Moller)
>Michael Fesser wrote:
>Additionally a Location header requires an absolute URL.

Erm...
I think that requirement was dropped some time ago.
HTTP was dropped? Damn. ;)

14.30 Location
http://www.w3.org/Protocols/rfc2616/....html#sec14.30
>And all browsers I have ever seen support the relative URL.
But you haven't seen all. And browsers are not the only user agents. A
bug doesn't become less of a bug, just because it works in the majority.

Micha
Jan 31 '07 #8
Erwin Moller:

[re HTTP Location header]
And all browsers I have ever seen support the relative URL.
The question is have you ever seen a browser that doesn't
support absolute URLs?

--
Jock

Jan 31 '07 #9
On 30 Jan 2007 22:17:11 -0800, bo*********@gmail.com wrote:
>
function Redirect($location = "")
{
if (headers_sent())
{
if (!$location)
.....................
}
else
{
if(!$location)
.............
....
Huh? How's that gonna work?

Jonesy
--
Marvin L Jones | jonz | W3DHJ | linux
38.24N 104.55W | @ config.com | Jonesy | OS/2
*** Killfiling google posts: <http://jonz.net/ng.htm>
Jan 31 '07 #10
John Dunlop wrote:
Erwin Moller:

[re HTTP Location header]
>And all browsers I have ever seen support the relative URL.

The question is have you ever seen a browser that doesn't
support absolute URLs?
lol, some browser that would be!
;-)

Erwin
>
--
Jock
Jan 31 '07 #11
Erwin Moller wrote:
John Dunlop wrote:
>>And all browsers I have ever seen support the relative URL.
The question is have you ever seen a browser that doesn't
support absolute URLs?

lol, some browser that would be!
Somewhere, somehow, you just know... there's an open sores
project that's trying to accomplish that.
Jan 31 '07 #12
Michael Fesser wrote:
.oO(Erwin Moller)
>>Michael Fesser wrote:
>>Additionally a Location header requires an absolute URL.

Erm...
I think that requirement was dropped some time ago.

HTTP was dropped? Damn. ;)
Hope not, then I am out of work!
And since I am really useless without internet...
>
14.30 Location
http://www.w3.org/Protocols/rfc2616/....html#sec14.30
Hmm yes. That sounds convincing.
Never trusts rfcs not recommended by me. ;-)

Here is one for you:
http://www.ietf.org/rfc/rfc3986.txt

It clearly describes relative referencing. (Part 4 and 5 mainly)

But judge for yourself.
>
>>And all browsers I have ever seen support the relative URL.

But you haven't seen all. And browsers are not the only user agents. A
bug doesn't become less of a bug, just because it works in the majority.
Well, that may be true.
I only aim my php for internetbrowsers, so I don't know jack about other
agents.
Thanks for the warning though.

Regards,
Erwin Moller
>
Micha
Jan 31 '07 #13
..oO(Erwin Moller)
>Michael Fesser wrote:
>>
14.30 Location
http://www.w3.org/Protocols/rfc2616/....html#sec14.30

Hmm yes. That sounds convincing.
Never trusts rfcs not recommended by me. ;-)

Here is one for you:
http://www.ietf.org/rfc/rfc3986.txt

It clearly describes relative referencing. (Part 4 and 5 mainly)
I'm familiar with it, but even the most recent and generalized RFC for
URI syntax doesn't change the meaning of "absolute URI", which is
required in the HTTP RFC. RFC 3986 just defines what an absolute URI
actually is.
>But you haven't seen all. And browsers are not the only user agents. A
bug doesn't become less of a bug, just because it works in the majority.

Well, that may be true.
I only aim my php for internetbrowsers, so I don't know jack about other
agents.
Thanks for the warning though.
I can remember someone having a strange problem with using a relative
URI and a query string in a Location header, which didn't work in Lynx
or something like that. The problem vanished after changing to an
absolute URI. It was posted to a German newsgroup, but I didn't bookmark
it and can't find it at Google Groups at the moment ... :(

Of course it doesn't really prove anything, but at least it shows that
there might be problems, which can easily be avoided by just following
the standards. Be it HTML, CSS or HTTP - it's always a good idea to
adhere to the written standards, because then it's not your fault if
something goes wrong.

Micha
Jan 31 '07 #14
On Wed, 31 Jan 2007 08:08:54 -0800, Allodoxaphobia <bi********@config.com
wrote:
On 30 Jan 2007 22:17:11 -0800, bo*********@gmail.com wrote:
>>
function Redirect($location = "")
{
if (headers_sent())
{
if (!$location)
.....................
> }
else
{
if(!$location)
.............
....

Huh? How's that gonna work?

Jonesy
It may, or may not, since it relies on client side scripting. Basically,
it checks if headers have been sent, if so, it tires to "redirect" using
JavaScript, or else it will use PHP's header function to redirect.

--
Curtis, http://dyersweb.com
Feb 1 '07 #15
Michael Fesser wrote:
.oO(Erwin Moller)
>>Michael Fesser wrote:
>>>
14.30 Location
http://www.w3.org/Protocols/rfc2616/....html#sec14.30

Hmm yes. That sounds convincing.
Never trusts rfcs not recommended by me. ;-)

Here is one for you:
http://www.ietf.org/rfc/rfc3986.txt

It clearly describes relative referencing. (Part 4 and 5 mainly)

I'm familiar with it, but even the most recent and generalized RFC for
URI syntax doesn't change the meaning of "absolute URI", which is
required in the HTTP RFC. RFC 3986 just defines what an absolute URI
actually is.
Hi Micha,

For clearity's sake: I completely agree with you that sticking to the
standards makes sense in almost all circumstances.
Deciding WHO decides what the standards are is my current problem.

My meager knowledge of picking the right RFC is to blame. I have dived into
a few, but I have trouble deciding on their 'weight'/importance.

I wonder, which RFC are considered to define standards by most people when
it comes to HTTP and the like?
Do you have/know of some list?

I am a bit confused because just the other day somebody in some javascript
newsgroup made it clear that just the fact somebody dumps a RFC doesn't
make it worth your while.
This is NOT my area of expertise, and I wonder which ones are worth reading
and which not. How do you/others approach that?

TIA

Regards,
Erwin Moller

>>But you haven't seen all. And browsers are not the only user agents. A
bug doesn't become less of a bug, just because it works in the majority.

Well, that may be true.
I only aim my php for internetbrowsers, so I don't know jack about other
agents.
Thanks for the warning though.

I can remember someone having a strange problem with using a relative
URI and a query string in a Location header, which didn't work in Lynx
or something like that. The problem vanished after changing to an
absolute URI. It was posted to a German newsgroup, but I didn't bookmark
it and can't find it at Google Groups at the moment ... :(

Of course it doesn't really prove anything, but at least it shows that
there might be problems, which can easily be avoided by just following
the standards. Be it HTML, CSS or HTTP - it's always a good idea to
adhere to the written standards, because then it's not your fault if
something goes wrong.

Micha
Feb 1 '07 #16
Erwin Moller wrote:
I wonder, which RFC are considered to define standards by most people when
it comes to HTTP and the like?
Do you have/know of some list?
Wow- you'd have to use several RFC's for that.
Most to all of the RFC's reference other RFC's.
For example - the ones for HTTP requires a knowledge of the ones
for DNS - and likley httpS as well.

This is NOT my area of expertise, and I wonder which ones are worth reading
and which not. How do you/others approach that?
Feb 1 '07 #17
Erwin Moller:
My meager knowledge of picking the right RFC is to blame. I have dived into
a few, but I have trouble deciding on their 'weight'/importance.
http://www.rfc-editor.org/

--
Jock

Feb 1 '07 #18
John Dunlop wrote:
Erwin Moller:
>My meager knowledge of picking the right RFC is to blame. I have dived
into a few, but I have trouble deciding on their 'weight'/importance.

http://www.rfc-editor.org/

--
Jock
Hi,

Thanks for the guidance.
This is from their FAQ:

http://www.rfc-editor.org/rfcfaq.html

Are all RFCs Internet standards documents?
In a word, "NO!".

Many RFCs have Informational or Experimental status and do not represent any
kind of standard. They contain information that may be useful or important
to retain in this archival document series.
This is important to understand, because unscrupulous marketeers and a
careless trade press sometimes falsely suggest that every RFC represents a
standard, or that all standards have equal weight. The relationship among
Internet technical specifications is often complex.

How can one tell where in the standards track an RFC is?
Consult the online document "Internet Official Protocol Standards". We
periodically publish a snapshot of this information as an RFC whose number
is divisible by 100; the latest such RFC is STD 1.

These links are also on the RFC Search and Retrieval page.

Which answers my question. :-)

Thanks.

Regards,
Erwin Moller
Feb 1 '07 #19

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

Similar topics

8
by: Manu | last post by:
Hi there, I am using a perl script to generate this html page which just redirects users to my ftp server. The problem is I get a "page cannot be displayed" in IE 6.0 (haven't tried other...
2
by: Rick N. Backer | last post by:
Hello folks, Novice type question here. I'm working with a very simple app here that takes a series of strings from the console. Once the end user has finished inputting the strings they are...
52
by: Gerard M Foley | last post by:
Can one write a webpage which is not displayed but which simply redirects the user to another page without any action by the user? Sorry if this is simple, but I am sometimes simple myself. ...
7
by: Steph | last post by:
Bonjour, Je souhaite lancer une redirection vers un fichier php via SRC= dans une condition if (voir ci-dessous en bas du script) mais la redirection ne fonctionne pas. Par contre la condition...
2
by: John Drako | last post by:
I have a database with a lot of links. Every so often I run a script to verify if the URLs are still valid. I weed out the ones with the 404 response. However, many responses are of the 303 kind...
8
by: Luciano A. Ferrer | last post by:
Hi! I was following the http://www.seomoz.org/articles/301-redirects.php article, trying to do that with one of my test sites I added this to the .htaccess file: RewriteEngine On RewriteCond...
13
by: souissipro | last post by:
Hi, I have written a C program that does some of the functionalities mentionned in my previous topic posted some days ago. This shell should: 1- execute input commands from standard input,...
1
by: comp.lang.php | last post by:
require_once("/users/ppowell/web/php_global_vars.php"); if ($_GET) { // INITIALIZE VARS $fileID = @fopen("$userPath/xml/redirect.xml", 'r'); $stuff = @fread($fileID,...
1
by: Mike Hofer | last post by:
I really need some help, and I'd appreciate any that you folks can provide. The ASP.NET application in question uses version 1.1 of the .NET Framework. All of the pages use a common base class...
3
by: postindex | last post by:
Can I get whole commandline not only argument list. 1. When I command like this $ a.py filename 2. sys.argv is returns only argument list Is there a way to find out 'redirection'...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...

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.