|
Posted by Oli Filth on 11/15/05 14:14
John wrote:
> On 15 Nov 2005 02:44:40 -0800, "Oli Filth" <catch@olifilth.co.uk>
> wrote:
>
> >John wrote:
> >> On 14 Nov 2005 04:56:30 -0800, "Gazornenplat" <ianbambury@gmail.com>
> >> wrote:
> >>
> >> ><?php
> >> >$page='page2.php'; // set page to anything you like via your lookup
> >> >if(isset($_REQUEST['data']))
> >> >{
> >> > echo "<script>document.location.replace('$page');</script>";
> >> > exit; // Stops further pointless processing
> >> >}
> >> >echo isset($_REQUEST['data']);
> >> >?>
> >> ><html>
> >> ><head><title></title></head>
> >> ><body>
> >> ><form>
> >> ><input name="data" type="text">
> >> ><input type="submit">
> >> ></form>
> >> ></body>
> >> ></html>
> >>
> >> Thanks for the suggestions and to Ian and Gazornenplat
> >> document.replace worked perfectly.
> >>
> >> Curious to know what this is doing differently to windows.location
> >> though.
> >>
> >
> >IMO, Philip's suggestion(s) would be far more appropriate.
> >
> >If you're using PHP, why not use it's ability to create an "official"
> >HTTP redirect, rather than rely on Javascript?
> >
> >Using JS only leads to problems (as you've seen), and may be disabled
> >by the user, rendering your navigation inoperable.
> >
> >That's one of the reason PHP exists! To allow you to avoid doing things
> >crappily and unreliably in JS, replacing it with an elegant, reliable
> >server-side solution.
>
> Thanks Oli
>
> It may be elegant but I get the ubiquitous 'headers already sent'
> error. Javascript solves this easily.
Well, JS doesn't solve this, it replaces this easily-fixable problem
with far more caveats and unfixable problems...
> What is the simple solution to that problem (without me having to read
> a 176 page document).
You could try going to the manual page for header(),
http://php.net/header, where you will find the "ubiquitous" solution to
this "ubiquitous" problem ;) :
" Remember that header() must be called before any actual output is
sent, either by normal HTML tags, blank lines in a file, or from PHP.
It is a very common error to read code with include(), or require(),
functions, or another file access function, and have spaces or empty
lines that are output before header() is called. The same problem
exists when using a single PHP/HTML file."
Flying by night, i.e. just typing in functions and hoping they work
without reading about how to use them, is generally not the recommended
way of programming.
--
Oli
Navigation:
[Reply to this message]
|