You are here: Re: script in body « PHP Programming Language « IT news, forums, messages
Re: script in body

Posted by Kimmo Laine on 06/20/05 17:46

"Sentinel" <support@elma.hr> kirjoitti
viestissδ:d95r6k$36p$2@ss405.t-com.hr...
> Kimmo Laine 17.6.2005 19:27:59 <d8v11i$ot7$1@phys-news1.kolumbus.fi>
> eternal.erectionN0.5P@Mgmail.com comp.lang.javascript Kimmo
>
>> "Sentinel" <support@elma.hr> kirjoitti
>> viestissδ:d8u71d$e98$1@ss405.t-com.hr...
>> > how can i place a script in body (it must be ran automaticly when
>> > html interpreter reaches it) that will redirect to another page?
>> >
>> >
>> > what i am doing is
>> >
>> > checking in php if login is successful (php script is in javascript
>> > that is in body) and if so i will print out the url to wich the
>> > javascript must redirect the browser
>> >
>> >
>> > <body>
>> > <script language="javascript">
>> > window.location=<?php a lots of ifs thens and elses and finaly print
>> > "index2.php"; ?>
>> > </script>
>> > </body>
>> >
>> >
>> >
>> > everything works fine but he browser doesn't redirect...
>> >
>> > the page source shows
>> > <body>
>> > <script language="javascript">
>> > window.location=index2.php
>> > </script>
>> > </body>
>>
>> Ditch the javascript and redirect with php directly
>> <?php header("Location: index2.php"); ?>
>
> can i send any data to the child page this way?


Yes, via GET method.

<?php header("Location: index2.php?foo=1&bar=2"); ?>
Parameters foo and bar are now available to index2.php. Oh and I should
mention also, that the example I gave you works in most browsers, but the
standard says you need to always always include the entire address, and not
just the relative filename. In other words: always use
<?php header("Location: http://www.your-domain.com/path/to/index2.php"); ?>
and never ever use
<?php header("Location: index2.php"); ?> without the entire url.

I should also mention that header data must be sent before any output. You
can't print or echo anything before you've sent headers.

Copy & Follow-up to: comp.lang.php
--
"I am pro death penalty. That way people learn
their lesson for the next time." -- Britney Spears

eternal.erectionN0@5P4Mgmail.com

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация