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

php redirect

here is the entire thread
From: "Kimmo Laine" <et*******************@Mgmail.com>
Subject: Re: script in body
Date: Mon, 20 Jun 2005 17:46:28 +0300
Message-ID: <d9**********@phys-news1.kolumbus.fi>
Lines: 64

"Sentinel" <su*****@elma.hr> kirjoitti
viestissä:d9**********@ss405.t-com.hr...
Kimmo Laine 17.6.2005 19:27:59 <d8**********@phys-news1.kolumbus.fi>
et*******************@Mgmail.com comp.lang.javascript Kimmo
"Sentinel" <su*****@elma.hr> kirjoitti
viestissä:d8**********@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

what i need is the ability to write something to the user and then
redirect him or her to index2 or index

--
What's the point in running when the light at the end of the tunnel iz
just another train...
Jul 17 '05 #1
2 2290
An noise sounding like Sentinel said:
what i need is the ability to write something to the user and then
redirect him or her to index2 or index

<script>
<!--
top.location.replace('foo.php');
-->
</script>

Echo that when you're ready to redirect. Will only work on JS enabled
browsers.

Dave.
--

/(bb|[^b]{2})/
Trees with square roots don't have very natural logs.

Jul 17 '05 #2
David Gillen 21.6.2005 15:47:43
<sl*******************@carbon.redbrick.dcu.ie> Be****@RedBrick.DCU.IE
comp.lang.php David
<script>
<!--
top.location.replace('foo.php');
-->
</script>


thanks

--
What's the point in running when the light at the end of the tunnel iz
just another train...
Jul 17 '05 #3

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

Similar topics

10
by: Bob Garbados | last post by:
forgive my ignorance, as I'm new to php coming from a ms background... If I create a page named redirect.php and it's only content is: <?php header("Location: http://www.google.com"); ?>...
3
by: Paul | last post by:
I'm not getting the results I want when I use Response.Redirct in a ASP page. I enter this line of code in a asp page from domain1.com. Response.Redirect...
7
by: Donna Hawkins | last post by:
I want to use javascript to redirect to a URL which has been passed as a variable (in php). I have searched but cannot find any solution. I think this code is a basic redirect: <script...
1
by: Peter Kirk | last post by:
Hi there I have a program written by another company (it's a "web control" which returns a web-page: can I compare this to a servlet in the Java world?), which they think is causing problems on...
2
by: Mark Dengler | last post by:
Is it possible to do a Response.Redirect to multiple URLs? I have tried the following and it simply ignores the first redirect: Response.Redirect("test.aspx", false);...
3
by: Justin | last post by:
Hi, Im confused here over the usage of Response.Redirect and Server.Transfer. I used frameset for my work, what are the proper usages of the two methods that seems working similar.. The...
6
by: Sam | last post by:
I have some issues with HTTP Headers and I was hoping for some pointers or references to good articles. Here is the problem. I have 6 .aspx pages, each page contains a common .ascx. This ascx...
6
by: Peter Row | last post by:
Hi, I am writing a DLL in VB.NET that implements IHttpHandler.ProcessRequest. This code calls a sub and I need to know if that sub did a response redirect or not. Specifically I need to know...
5
by: venner | last post by:
I'm having an issue with an ASP.NET website after upgrading to ASP.NET 2.0. The website makes use of a central authentication service (CAS) provided at the university I work for. Each page checks...
10
by: Eirik Eldorsen | last post by:
How can I 301 redirect www.example.com/default.aspx to www.example.com without using ISAPI filters?
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: 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:
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...

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.