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

Force user to another page

Hi,

How would I go about "forcing" a user from one page to another?

I have a very simple random question/answer entrance requirement for an
e-mail form. After 3 page views most people are going to have
successfully submitted their e-mail (enter/validate as human, enter
message, send the message). If someone or something decides to start
banging on any of the pages and increses the views count too far I want
to kick them out to an explanatory page (just in case it's really a
little old lady or whatever).
Counting views and getting the error state is easy. But how do I
"force" the visitor off to that "explanatory" page?

Or is there a better way to treat this situation?
Or is there any way to easily just disconnect them from my site somehow?
I thought about using sleep or usleep but ... not sure how reliable that
might be and it could really PO some poor little old lady.
This is for a non-profit agency's web site so I need to be "gentle"
if I can<g>.

TIA,

Twayne



Jun 27 '08 #1
41 2764
Twayne wrote:
Hi,

How would I go about "forcing" a user from one page to another?

I have a very simple random question/answer entrance requirement for an
e-mail form. After 3 page views most people are going to have
successfully submitted their e-mail (enter/validate as human, enter
message, send the message). If someone or something decides to start
banging on any of the pages and increses the views count too far I want
to kick them out to an explanatory page (just in case it's really a
little old lady or whatever).
Counting views and getting the error state is easy. But how do I
"force" the visitor off to that "explanatory" page?

Or is there a better way to treat this situation?
Or is there any way to easily just disconnect them from my site somehow?
I thought about using sleep or usleep but ... not sure how reliable that
might be and it could really PO some poor little old lady.
This is for a non-profit agency's web site so I need to be "gentle"
if I can<g>.

TIA,

Twayne



Look at the header() function call, specifically header('Location:....');

sleep() won't do anything other than tick off your users because they
won't get a page back.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 27 '08 #2
Look at the header() function call, specifically header('Location:....');
An additional word of caution about header() -- you should not call header()
unless no other text has been output by your script yet. In other words,
determine whether or not to redirect with header() before producing any part of
the readable page for your users. For good measure, call exit() afterward to be
sure nothing else gets executed.

<?php
// Redirect user
header("Location: redirect_page.html");
exit();
?>

Best,
Michael
Jun 27 '08 #3
Michael Berkowski wrote:
>
>Look at the header() function call, specifically header('Location:....');

An additional word of caution about header() -- you should not call
header() unless no other text has been output by your script yet. In
other words, determine whether or not to redirect with header() before
producing any part of the readable page for your users. For good
measure, call exit() afterward to be sure nothing else gets executed.

<?php
// Redirect user
header("Location: redirect_page.html");
No HTTP response code?
exit();
?>
I'm a little confused by how header works. Is it pretty much just an
echo? I'm assuming when a server parses a page, it has to send some
content-type out, probably: Content-type: text/html. Does the parser
wait until it sees that no header is being sent before it does that?

Also, what about setcookie, does that implicitly call something like header?

I haven't gotten this far with my PHP yet...
>
Best,
Michael
Jun 27 '08 #4
Jeff wrote:
> header("Location: redirect_page.html");

No HTTP response code?
It implies "302 Moved" IIRC.
I'm a little confused by how header works. Is it pretty much just an
echo?
Yes, but only for the header part of the HTTP protocol.
I'm assuming when a server parses a page, it has to send some
content-type out, probably: Content-type: text/html. Does the parser
wait until it sees that no header is being sent before it does that?
The PHP engine outputs all default headers on the first echo() (or any
function that outputs anything out of standard output). Custom header()
calls will override those defaults.
Also, what about setcookie, does that implicitly call something like
header?
Kinda, you got the idea.

--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

Un ordenador no es un televisor ni un microondas, es una herramienta
compleja.
Jun 27 '08 #5
Jeff wrote:
Michael Berkowski wrote:
>>
>>Look at the header() function call, specifically
header('Location:....');

An additional word of caution about header() -- you should not call
header() unless no other text has been output by your script yet. In
other words, determine whether or not to redirect with header() before
producing any part of the readable page for your users. For good
measure, call exit() afterward to be sure nothing else gets executed.

<?php
// Redirect user
header("Location: redirect_page.html");

No HTTP response code?
If you don't supply one, PHP does.
> exit();
?>

I'm a little confused by how header works. Is it pretty much just an
echo? I'm assuming when a server parses a page, it has to send some
content-type out, probably: Content-type: text/html. Does the parser
wait until it sees that no header is being sent before it does that?
Not at all. Headers are sent by the web server when it detects any data
being sent. The header() function tells the web server to modify those
headers. Of course, the headers can't be sent yet.
Also, what about setcookie, does that implicitly call something like
header?
Similar, yet.
I haven't gotten this far with my PHP yet...
>>
Best,
Michael
But it's like needing to know how the processor performs floating point
addition - you don't have to worry about any of this.

All you really need to know is that the header-related calls like
header(), set_cookie() and session_start() need to be called before ANY
output (including white space) from your script. But this is all well
documented in the manual, and the errors are clear if you have them enabled.

It's the beauty of using higher level languages.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 27 '08 #6
Iván Sánchez Ortega wrote:
Jeff wrote:
>> header("Location: redirect_page.html");
No HTTP response code?

It implies "302 Moved" IIRC.
You made me curious to check on the details of the HTTP response code. From the
docs at http://www.php.net/manual/en/function.header.php

"The second special case is the "Location:" header. Not only does it send this
header back to the browser, but it also returns a REDIRECT (302) status code to
the browser unless some 3xx status code has already been set."

I got quite nervous when I saw your response that I had been sending incorrect
HTTP codes in all my redirects, but you got the 302 right with the wrong
description. Thanks for nudging me to pay more attention to that in the future.

-Michael
Jun 27 '08 #7
Iván Sánchez Ortega wrote:
It implies "302 Moved" IIRC.
What's the different between 302 and 301?
I used 301 before, it worked.
Jun 27 '08 #8
On 23 Jun, 13:26, GuangXiN <xvt...@gmail.comwrote:
Iván Sánchez Ortega wrote:
It implies "302 Moved" IIRC.

What's the different between 302 and 301?
I used 301 before, it worked.
What's the difference between someone who uses a simple Google search
to find the answer to common questions and those who expect others to
do it for them?

http://www.google.co.uk/search?q=dif...ient=firefox-a
Jun 27 '08 #9
Captain Paralytic wrote:
On 23 Jun, 13:26, GuangXiN <xvt...@gmail.comwrote:
>Iván Sánchez Ortega wrote:
>>It implies "302 Moved" IIRC.
What's the different between 302 and 301?
I used 301 before, it worked.

What's the difference between someone who uses a simple Google search
to find the answer to common questions and those who expect others to
do it for them?

http://www.google.co.uk/search?q=dif...ient=firefox-a
Why even have a newsgroup when you can pretty much find anything by
searching the web? Maybe to provoke conversation and community?
Jun 27 '08 #10
On Mon, 23 Jun 2008 06:23:19 -0700, FutureShock wrote:
Captain Paralytic wrote:
>What's the difference between someone who uses a simple Google search
to find the answer to common questions and those who expect others to
do it for them?

http://www.google.co.uk/search?q=dif...ient=firefox-a
Why even have a newsgroup when you can pretty much find anything by
searching the web? Maybe to provoke conversation and community?
If this were a question that was applicable to PHP code and correct or
incorrect PHP coding, or otherwise directly associated with PHP,
henceforth known as "a PHP question", then you may have gotten a
different kind of answer.

--
20. Despite its proven stress-relieving effect, I will not indulge in maniacal
laughter. When so occupied, it's too easy to miss unexpected developments
that a more attentive individual could adjust to accordingly.
--Peter Anspach's list of things to do as an Evil Overlord
Jun 27 '08 #11
Twayne wrote:
>Hi,

How would I go about "forcing" a user from one page to another?

I have a very simple random question/answer entrance requirement for
an e-mail form. After 3 page views most people are going to have
successfully submitted their e-mail (enter/validate as human, enter
message, send the message). If someone or something decides to start
banging on any of the pages and increses the views count too far I
want to kick them out to an explanatory page (just in case it's
really a little old lady or whatever).
Counting views and getting the error state is easy. But how do I
"force" the visitor off to that "explanatory" page?

Or is there a better way to treat this situation?
Or is there any way to easily just disconnect them from my site
somehow? I thought about using sleep or usleep but ... not sure how
reliable that might be and it could really PO some poor little old
lady. This is for a non-profit agency's web site so I need to be
"gentle" if I can<g>.

TIA,

Twayne
....
>
Look at the header() function call, specifically
header('Location:....');
sleep() won't do anything other than tick off your users because they
won't get a page back.
Hi Jerry,
I'm at a bit of a loss here; a couple clarifying comments maybe?

Say entries are made on page 1; no validation here
Validations are done on page2
I can't use Header Location because I can't have performed any output
without already having initiating a header, right? Which leaves out
doing another Header Location.

Just the act of comparing the random generated password to the user
entered password seems to have initiated headers, going by the error
messages. In fact, I'm not sure yet but using Session Variables period
seems to have initiated the headers?

Sorry I'm so ignorant about these things; still getting my head
wrapped around a lot of PHP basics.

I thought about using a plain html link followed by Exit, but that
exposes the html and thus an access for malcontents, right? Besides,
the visitor has to click it for it to work.

sleep() occurred to me because, by the time I get to that point, I've
(hopefully) identified a malcontent so pissing him off is the whole
idea. If it's a bot it should go away but if it's a user, for a short
period of time at least, they should just figure the server's slowed for
a second, and I can come back to them.
But that feels like walking a tightrope.

I guess I could just silently ship them back to the entrance page but
that's a little crude , and besides, it helps a bot or a malcontent get
restarted all over again.

Am I overthinking this?

All I really want to do is force an obnoxious visitor out to some
explanatory page and say quit doing that or I'll ban you eventually or
something similar, and maybe a Help explanation of what to do to get in.
Honest people should never see it; only malcontents and bots. I think
I already know how to get around the Back Button; seems to work anyway,
but that's just a stub so far; haven't implemented it in the form code
yet.

I've found other code snippets that seem to do what I want, but they use
pointers and all sorts of things I haven't come across yet; seems like
it should be possible to do what I want the way I'm doing it, but ...
obviously needs help<g>!

Thanks again,

Twayne


Jun 27 '08 #12
Michael Berkowski wrote:
>
>Look at the header() function call, specifically header('Location:....');

An additional word of caution about header() -- you should not call
header() unless no other text has been output by your script yet. In
other words, determine whether or not to redirect with header() before
producing any part of the readable page for your users. For good
measure, call exit() afterward to be sure nothing else gets executed.

<?php
// Redirect user
header("Location: redirect_page.html");
exit();
?>

Best,
Michael
I ALWAYS use exit() after the header("Location....") statement. I have
found in the past that sometimes without the exit() it continued on an
did the rest of the page before doing the header, rather than an
unconditional transfer.
Jun 27 '08 #13
Twayne wrote:
I'm at a bit of a loss here; a couple clarifying comments maybe?
Think of header("Location: the_place"); as something like a GOTO
statement. It causes the browser to GOTO that page. The one requisite
is that you cannot have already started output to the current page.

So the sequence is like this:

Page presented.
User does something to cause the page to post to the server.
Server code (php) executes.
....don't put any print or echo statements here...
header call made that send the browser to the new page.

In the header call you can include arguments like
header("Location: foo.php?user=Twayne&admin=3");

so that you can use $_GET['user'] and $_GET['admin'] in foo.php
Jun 27 '08 #14
Twayne wrote:
>Twayne wrote:
>>Hi,

How would I go about "forcing" a user from one page to another?

I have a very simple random question/answer entrance requirement for
an e-mail form. After 3 page views most people are going to have
successfully submitted their e-mail (enter/validate as human, enter
message, send the message). If someone or something decides to start
banging on any of the pages and increses the views count too far I
want to kick them out to an explanatory page (just in case it's
really a little old lady or whatever).
Counting views and getting the error state is easy. But how do I
"force" the visitor off to that "explanatory" page?

Or is there a better way to treat this situation?
Or is there any way to easily just disconnect them from my site
somehow? I thought about using sleep or usleep but ... not sure how
reliable that might be and it could really PO some poor little old
lady. This is for a non-profit agency's web site so I need to be
"gentle" if I can<g>.

TIA,

Twayne
...
>Look at the header() function call, specifically
header('Location:....');
sleep() won't do anything other than tick off your users because they
won't get a page back.

Hi Jerry,
I'm at a bit of a loss here; a couple clarifying comments maybe?

Say entries are made on page 1; no validation here
Validations are done on page2
I can't use Header Location because I can't have performed any output
without already having initiating a header, right? Which leaves out
doing another Header Location.

Just the act of comparing the random generated password to the user
entered password seems to have initiated headers, going by the error
messages. In fact, I'm not sure yet but using Session Variables period
seems to have initiated the headers?
No, sending ANY output to the client (including white space) sends the
headers. session_start() doesn't send headers - all it does is read the
cookie which the client already sent and initiate the session.
Sorry I'm so ignorant about these things; still getting my head
wrapped around a lot of PHP basics.

I thought about using a plain html link followed by Exit, but that
exposes the html and thus an access for malcontents, right? Besides,
the visitor has to click it for it to work.
True, but the html is exposed anyway. You can't hide it (browsers can
be set to ignore redirects, for instance).
sleep() occurred to me because, by the time I get to that point, I've
(hopefully) identified a malcontent so pissing him off is the whole
idea. If it's a bot it should go away but if it's a user, for a short
period of time at least, they should just figure the server's slowed for
a second, and I can come back to them.
But that feels like walking a tightrope.
Not a good use for sleep().
I guess I could just silently ship them back to the entrance page but
that's a little crude , and besides, it helps a bot or a malcontent get
restarted all over again.
Yes, but what's to stop them from starting all over again, anyway? If
you're that concerned about security, you need to disable their login id
and send them an email, telling them how to re-enable it.
Am I overthinking this?
Probably.
All I really want to do is force an obnoxious visitor out to some
explanatory page and say quit doing that or I'll ban you eventually or
something similar, and maybe a Help explanation of what to do to get in.
Honest people should never see it; only malcontents and bots. I think
I already know how to get around the Back Button; seems to work anyway,
but that's just a stub so far; haven't implemented it in the form code
yet.
And how are you going to ban them? IP addresses are not reliable.
Neither are cookies.
I've found other code snippets that seem to do what I want, but they use
pointers and all sorts of things I haven't come across yet; seems like
it should be possible to do what I want the way I'm doing it, but ...
obviously needs help<g>!

Thanks again,

Twayne
It's not that hard.

When you get the "headers already sent" message, it tells you the file
and line which send output to the client. Look there to find out why
something has been sent.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 27 '08 #15
Michael Berkowski wrote:
>>
>>Look at the header() function call, specifically
header('Location:....');

An additional word of caution about header() -- you should not call
header() unless no other text has been output by your script yet. In
other words, determine whether or not to redirect with header()
before producing any part of the readable page for your users. For
good measure, call exit() afterward to be sure nothing else gets
executed. <?php
// Redirect user
header("Location: redirect_page.html");
exit();
>>>

Best,
Michael

I ALWAYS use exit() after the header("Location....") statement. I
have found in the past that sometimes without the exit() it continued
on an did the rest of the page before doing the header, rather than an
unconditional transfer.
I came across some info on that myself; sounds like excellent advice. I
can't refer to it by URL now (too much surfing) but it did a good job of
describing how the code can continue on after the visitor has left the
page, and cited some "interesting" examples, including input from that
visitor after he's left.
I put it into my "special notes" file.

Regards,

Twayne

Jun 27 '08 #16
Twayne wrote:
>>Twayne wrote:
....
>
No, sending ANY output to the client (including white space) sends the
headers. session_start() doesn't send headers - all it does is read
the cookie which the client already sent and initiate the session.
Yeah, I bit the bullet and dug into it more closely. Amazing how much
sandbox time can clarify things<g>. It pays to take one's time with
those things. They're making more sense now, thanks to your gentle
prodding.

....
>
Yes, but what's to stop them from starting all over again, anyway? If
you're that concerned about security, you need to disable their login
id and send them an email, telling them how to re-enable it.
No, nothing like super security in mind here. Just an attempt to thwart
bots and malcontents. If an expert decides he wants in, he's going to
accomplish it; I'm aware of that much.

....
>
And how are you going to ban them? IP addresses are not reliable.
Neither are cookies.
lol, I know! Poor choice of words but it's worked reasonably in the
past for this site at least twice but only with John-Doe types off the
street that don't know an IP from their keyboard. It's just an htaccess
file so ... .
I did get hacked once by a dog-fight trainer it turned out according
to the attempted spam, but his tripe only went to me I think; pretty
sure nothing got out. Server Admin said there was no record of it, at
least. Scared me; that's an easy way to quickly lose a site! That
óne's parked at Netfirms; they're pretty good folk there as long as you
keep them advised.

....
It's not that hard.
Yeah, even the most complicated things are "simple" once a person
understands them! lol, LEARNING isn't the hard part; USING what I
learned is the hard part!
>
When you get the "headers already sent" message, it tells you the file
and line which send output to the client. Look there to find out why
something has been sent.
I can see that now I'm getting more used to them. It's a lot to absorb
all at once, but I'm learning to parse the error messages & warnings a
lot more accurately now! Those damned 'T-whatever' things drove me nuts
at first!

Regards,

Twayne
--
Wrong does not cease to be wrong
because the majority share in it. -Tolstoy

Jun 27 '08 #17
..oO(Michael Berkowski)
><?php
// Redirect user
header("Location: redirect_page.html");
exit();
?>
HTTP requires an absolute URL.

Micha
Jun 27 '08 #18
If you use the function header(); but, before that some content has
been outputted, then you can't move to the next location.
Try this one... This will redirect you to the mentioned url, whether
some data has been already outputted or not.

$url = 'http://www.igoogle.com';
OR
$url = 'filename.ext'; // Assuming the filename is in the current
directory.

$content = 1;
exit("
<meta
http-equiv=\"refresh\"
content=\"{$content};url={$url}\"
>
<script>
function doRefresh() {
window.location = '{$url}';
}
doRefreshTimeout = setTimeout(\"doRefresh()\" , ".
($content*1000).");
</script>
");

Enjoy.
Jun 27 '08 #19
su********@gmail.com wrote:
If you use the function header(); but, before that some content has
been outputted, then you can't move to the next location.
Try this one... This will redirect you to the mentioned url, whether
some data has been already outputted or not.

$url = 'http://www.igoogle.com';
OR
$url = 'filename.ext'; // Assuming the filename is in the current
directory.

$content = 1;
exit("
<meta
http-equiv=\"refresh\"
content=\"{$content};url={$url}\"
>
<script>
function doRefresh() {
window.location = '{$url}';
}
doRefreshTimeout = setTimeout(\"doRefresh()\" , ".
($content*1000).");
</script>
");

Enjoy.
Which may not work for several reasons, i.e. the user has disabled
javascript or the user has disabled meta refresh in the browser.

It's much better to just fix the problem and use the appropriate function.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 27 '08 #20
If you use the function header(); but, before that some content has
been outputted, then you can't move to the next location.
Try this one... This will redirect you to the mentioned url, whether
some data has been already outputted or not.

$url = 'http://www.igoogle.com';
OR
$url = 'filename.ext'; // Assuming the filename is in the current
directory.

$content = 1;
exit("
<meta
http-equiv=\"refresh\"
content=\"{$content};url={$url}\"
>
<script>
function doRefresh() {
window.location = '{$url}';
}
doRefreshTimeout = setTimeout(\"doRefresh()\" , ".
($content*1000).");
</script>
");

Enjoy.
Hmm, imo that's rather clever. I've had to do some reorganization, but
I think I'm going to get things in hand without having to go to jscript,
one of the "rules" right now.
Thanks,
Twayne
Jun 27 '08 #21
....
>
Which may not work for several reasons, i.e. the user has disabled
javascript or the user has disabled meta refresh in the browser.
....

Disable meta refresh? How do you do that?

Twayne
Jun 27 '08 #22
On 24 Jun, 13:42, "Twayne" <nob...@devnull.spamcop.netwrote:
...
Which may not work for several reasons, i.e. the user has disabled
javascript or the user has disabled meta refresh in the browser.

...

Disable meta refresh? How do you do that?

Twayne
It depends on the browser:
# In Opera 9 (Win/Mac): browse to opera:config#UserPrefs|
ClientRefresh, then deselect the option and restart Opera.
# Firefox 2 (Win/Mac): install the Web Developer's Toolbar and click
Disable $B"*(B Disable Meta Redirects.
# In Internet Explorer 6 and 7: go to Tools $B"*(B Internet options $B"*(B
Security tab $B"*(B Custom Level button $B"*(B Miscellaneous category $B"*(B set
"Allow META REFRESH" to Disable.
Jun 27 '08 #23
On 24 Jun, 13:39, "Twayne" <nob...@devnull.spamcop.netwrote:
If you use the function header(); but, before that some content has
been outputted, then you can't move to the next location.
Try this one... This will redirect you to the mentioned url, whether
some data has been already outputted or not.
$url = 'http://www.igoogle.com';
*OR
$url = 'filename.ext'; // Assuming the filename is in the current
directory.
$content = 1;
exit("
* * * *<meta
* * * *http-equiv=\"refresh\"
* * * *content=\"{$content};url={$url}\"
* * * *<script>
* * * *function doRefresh() {
* * * * * *window.location = '{$url}';
* * * *}
* * * *doRefreshTimeout = setTimeout(\"doRefresh()\" , ".
($content*1000).");
* * * *</script>
* *");
Enjoy.

Hmm, imo that's rather clever. *I've had to do some reorganization, but
I think I'm going to get things in hand without having to go to jscript,
one of the "rules" right now.
Errm, that IS jscript (or javascript)
Jun 27 '08 #24
Twayne wrote:
...
>Which may not work for several reasons, i.e. the user has disabled
javascript or the user has disabled meta refresh in the browser.
...

Disable meta refresh? How do you do that?

Twayne
Web Developer extension to Firefox does it, for one.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 27 '08 #25
FutureShock wrote:
Captain Paralytic wrote:
>On 23 Jun, 13:26, GuangXiN <xvt...@gmail.comwrote:
>>Iván Sánchez Ortega wrote:
It implies "302 Moved" IIRC.
What's the different between 302 and 301?
I used 301 before, it worked.

What's the difference between someone who uses a simple Google search
to find the answer to common questions and those who expect others to
do it for them?

http://www.google.co.uk/search?q=dif...ient=firefox-a
Why even have a newsgroup when you can pretty much find anything by
searching the web? Maybe to provoke conversation and community?
So Jerry stuckle can piss on you. What else?

Jun 27 '08 #26
Twayne wrote:
>Twayne wrote:
>>Hi,

How would I go about "forcing" a user from one page to another?

I have a very simple random question/answer entrance requirement for
an e-mail form. After 3 page views most people are going to have
successfully submitted their e-mail (enter/validate as human, enter
message, send the message). If someone or something decides to start
banging on any of the pages and increses the views count too far I
want to kick them out to an explanatory page (just in case it's
really a little old lady or whatever).
Counting views and getting the error state is easy. But how do I
"force" the visitor off to that "explanatory" page?

Or is there a better way to treat this situation?
Or is there any way to easily just disconnect them from my site
somehow? I thought about using sleep or usleep but ... not sure how
reliable that might be and it could really PO some poor little old
lady. This is for a non-profit agency's web site so I need to be
"gentle" if I can<g>.

TIA,

Twayne
...
>Look at the header() function call, specifically
header('Location:....');
sleep() won't do anything other than tick off your users because they
won't get a page back.

Hi Jerry,
I'm at a bit of a loss here; a couple clarifying comments maybe?
Of course you are. Jerry likes to look smart: sinc he has very little
raw material to do that with, he does it by making other people look stupid.

Terse, apparently 'intelligent', comments are his favorite way.
Jun 27 '08 #27
....
>>
Hmm, imo that's rather clever. I've had to do some reorganization,
but I think I'm going to get things in hand without having to go to
jscript, one of the "rules" right now.
Errm, that IS jscript (or javascript)
That's what I said: I thought I had things in hand WITHOUT having to go
to jscript. Speed reading gotcha here & I spose I coulda used more
words, but ... the idea's there.
Jun 27 '08 #28
FutureShock wrote:
>Captain Paralytic wrote:
>>On 23 Jun, 13:26, GuangXiN <xvt...@gmail.comwrote:
Iván Sánchez Ortega wrote:
It implies "302 Moved" IIRC.
What's the different between 302 and 301?
I used 301 before, it worked.

What's the difference between someone who uses a simple Google
search to find the answer to common questions and those who expect
others to do it for them?

http://www.google.co.uk/search?q=dif...ient=firefox-a
Why even have a newsgroup when you can pretty much find anything by
searching the web? Maybe to provoke conversation and community?

So Jerry stuckle can piss on you. What else?
Then it sounds like you should go play around in Google, not waste your
time here. Apparently you don't even realize when you go OT. Got
somethins useful to say? I'm interested; otherwise I'm learning to
ignore your name. I doubt I'm unique in that.
Jun 27 '08 #29
....
>
Of course you are. Jerry likes to look smart: sinc he has very little
raw material to do that with, he does it by making other people look
stupid.
Terse, apparently 'intelligent', comments are his favorite way.
Perhaps it isn't your way, but I am perfectly capable of my own thoughts
and opinions and certainly don't need the likes of you to prejudice
anything because you feel slighted or just like sour grapes. You'll
never lead by following. Whether Jerry's good bad or indifferent is
something I can decide; the likes of you only add credibility to those
you attempt to malign.
You wouldn't last two mintues in a professional newsgroup, know that?

Jun 27 '08 #30
Twayne wrote:
....
>
It's not that hard.

When you get the "headers already sent" message, it tells you the file
and line which send output to the client. Look there to find out why
something has been sent.

I'm not having a lot of luck with header redirects in my spaghetti, I
mean, code<g>.
BUT, I do think I've found a solution that'll work well for me; so
far so good in fact, and it still still allows the header redirects;
that's output buffering (ob_start() etc.).
Any comments or gotchas I should watch for?

Regards,

Twayne
Jun 27 '08 #31
Twayne wrote:
...
>Of course you are. Jerry likes to look smart: sinc he has very little
raw material to do that with, he does it by making other people look
stupid.
Terse, apparently 'intelligent', comments are his favorite way.

Perhaps it isn't your way, but I am perfectly capable of my own thoughts
and opinions and certainly don't need the likes of you to prejudice
anything because you feel slighted or just like sour grapes. You'll
never lead by following. Whether Jerry's good bad or indifferent is
something I can decide; the likes of you only add credibility to those
you attempt to malign.
You wouldn't last two mintues in a professional newsgroup, know that?
I wasn't talking to you when I said that. Don't intrude on other
people's conversations if you don't like what's said.
Jun 27 '08 #32
..oO(Twayne)
>If you use the function header(); but, before that some content has
been outputted, then you can't move to the next location.
Try this one... This will redirect you to the mentioned url, whether
some data has been already outputted or not.

$url = 'http://www.igoogle.com';
OR
$url = 'filename.ext'; // Assuming the filename is in the current
directory.

$content = 1;
exit("
<meta
http-equiv=\"refresh\"
content=\"{$content};url={$url}\"
> >
<script>
function doRefresh() {
window.location = '{$url}';
}
doRefreshTimeout = setTimeout(\"doRefresh()\" , ".
($content*1000).");
</script>
");

Enjoy.

Hmm, imo that's rather clever.
No. It's stupid, highly unreliable and may even cause usability
problems. Proper redirects are done on the HTTP level, period.

If you can't send an HTTP header because of previous output, then the
correct way is to restructure your code instead of adding such a hack.

Micha
Jun 27 '08 #33
..oO(Twayne)
>I'm not having a lot of luck with header redirects in my spaghetti, I
mean, code<g>.
BUT, I do think I've found a solution that'll work well for me; so
far so good in fact, and it still still allows the header redirects;
that's output buffering (ob_start() etc.).
Any comments or gotchas I should watch for?
It's still ugly and you should defeinitely restructure your code. But at
least output buffering is better than a dirty meta-refresh/JS hack.

Micha
Jun 27 '08 #34
..oO(The Natural Philosopher)
>Twayne wrote:
>>
Perhaps it isn't your way, but I am perfectly capable of my own thoughts
and opinions and certainly don't need the likes of you to prejudice
anything because you feel slighted or just like sour grapes. You'll
never lead by following. Whether Jerry's good bad or indifferent is
something I can decide; the likes of you only add credibility to those
you attempt to malign.
You wouldn't last two mintues in a professional newsgroup, know that?
I wasn't talking to you when I said that.
No? You directly replied to Twayne.
>Don't intrude on other
people's conversations if you don't like what's said.
He was one of the other people you were having a conversation with.
With such comments you don't need guys like Jerry to make you look
stupid, you're doing it perfectly well on your own.

Micha
Jun 27 '08 #35
Michael Fesser wrote:
.oO(Michael Berkowski)
><?php
// Redirect user
header("Location: redirect_page.html");
exit();
?>

HTTP requires an absolute URL.

Micha

No, it doesn't. I have used relative URLs like this one many, many times.
Jun 27 '08 #36
On 27 Jun, 13:05, sheldonlg <sheldonlgwrote:
Michael Fesser wrote:
.oO(Michael Berkowski)
<?php
* // Redirect user
* header("Location: redirect_page.html");
* exit();
?>
HTTP requires an absolute URL.
Micha

No, it doesn't. *I have used relative URLs like this one many, many times.
Well I hope you're not charging anyone for your work. This is a
disaster waiting to happen. I quote from the PHP manual:
"Note: HTTP/1.1 requires an absolute URI as argument to » Location:
including the scheme, hostname and absolute path, but some clients
accept relative URIs. You can usually use $_SERVER['HTTP_HOST'],
$_SERVER['PHP_SELF'] and dirname() to make an absolute URI from a
relative one yourself"
Jun 27 '08 #37
On Fri, 27 Jun 2008 05:21:29 -0700 (PDT)
Captain Paralytic <pa**********@yahoo.comwrote:

HTTP requires an absolute URL.
Micha
No, it doesn't. *I have used relative URLs like this one many, many times.
Well I hope you're not charging anyone for your work. This is a
disaster waiting to happen. I quote from the PHP manual:...
Thank you for pointing this out. I'll have a few instances to fix in the application I'm building now.
--
Michael Berkowski <be******@NOSPAMumn.edu>
Jun 27 '08 #38
..oO(sheldonlg)
>Michael Fesser wrote:
>.oO(Michael Berkowski)
>><?php
// Redirect user
header("Location: redirect_page.html");
exit();
?>

HTTP requires an absolute URL.

Micha


No, it doesn't.
Of course it does. Read the RFC.
>I have used relative URLs like this one many, many times.
A bug is a bug. The specification _requires_ an absolute URL. It doesn't
matter that most user agents also accept relative ones, because there's
no guarantee that all UAs will behave that way. And in fact not all do.

Micha
Jun 27 '08 #39
Michael Fesser wrote:
.oO(sheldonlg)
>Michael Fesser wrote:
>>.oO(Michael Berkowski)

<?php
// Redirect user
header("Location: redirect_page.html");
exit();
?>
HTTP requires an absolute URL.

Micha

No, it doesn't.

Of course it does. Read the RFC.
>I have used relative URLs like this one many, many times.

A bug is a bug. The specification _requires_ an absolute URL. It doesn't
matter that most user agents also accept relative ones, because there's
no guarantee that all UAs will behave that way. And in fact not all do.

Micha
OK, I stand corrected. From now on.....
Jun 27 '08 #40
Greetings, Michael Fesser.
In reply to Your message dated Friday, June 27, 2008, 17:41:14,
>>><?php
// Redirect user
header("Location: redirect_page.html");
exit();
?>

HTTP requires an absolute URL.

Micha


No, it doesn't.
Of course it does. Read the RFC.
>>I have used relative URLs like this one many, many times.
A bug is a bug. The specification _requires_ an absolute URL. It doesn't
matter that most user agents also accept relative ones, because there's
no guarantee that all UAs will behave that way. And in fact not all do.
In my experience, only IE used to correctly redirect relative Location:
headers...
I doubt it is not only one client that does.
--
Sincerely Yours, AnrDaemon <an*******@freemail.ru>

Jun 29 '08 #41
..oO(AnrDaemon)
>Greetings, Michael Fesser.
>A bug is a bug. The specification _requires_ an absolute URL. It doesn't
matter that most user agents also accept relative ones, because there's
no guarantee that all UAs will behave that way. And in fact not all do.

In my experience, only IE used to correctly redirect relative Location:
headers...
I doubt it is not only one client that does.
All modern web browsers can handle that (some show a warning). But older
ones may choke on it, especially if there's also a query string involved
(I can remember reports about this issue some years ago).

And then there's the whole bunch of user agents which you often can't
test easily: search engines, download managers, assistive devices ...

Just adhere to the spec and you won't have any problem.

Micha
Jun 30 '08 #42

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

Similar topics

2
by: Jonathan Driller | last post by:
I am attempting to block repeat downloads from a site. I need to have a landing page pass a referer to a secured page. I have tried a meta refresh redirect and several Javascript redirect...
3
by: Paul | last post by:
Hi, I'm using a little javascript to help my site's design to fit the visitor's entire browser window. Everything works great apart from one problem. If a visitor first loads the page and the...
2
by: VB Programmer | last post by:
How can I force the DayRender event of my Calendar to run/refresh? The calendar displays data from a database and I am allowing the user to filter out what data they see on the calendar. When...
8
by: Keith H | last post by:
I'm looking for a way to force the user to re-authenticate with their Windows username/password/domain after clicking the submit button on an ASP.NET page. This is for an internal application. ...
3
by: ABC | last post by:
I have a web site include three folders: public, admin and member. I place web.config files to admin and members folders only allow admin and members to access. If there are a user login as Demo...
2
by: Gamboz Matteo | last post by:
Hi all, I'm writing a widget that should enable the user to choose some item from a huge list that has a tree structure (~23000 items, node with max children = ~1600 kids (only 3 levels in the...
51
by: Paul Gorodyansky | last post by:
Hi, Ran into the following problem while trying to have a code to attach a Virtual Keyboard to any user's form: User clicks a button and my JavaScript changes outerHTML of say <textarea -...
2
by: cottonj | last post by:
is there anyway to force an event, like mouseover? I have a page that loads, and due to some complex js code (not mine) it fails to write labels to tabs until the user does a mouseover on the...
2
by: =?Utf-8?B?U2lsa0NpdHlGbG9yaWRh?= | last post by:
I have a web page "PgA" with a GridView. I open another page "PgB" in a new window. On PgB, they do some things that affect the underlying data for the GridView on PgA. When the user is done...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...

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.