Nov 21, 2009

Problem With Page Redirect - Help me out with this problem...

free web hosting
Open Discussion > MODERATED AREA > Computers > Programming Languages > PHP Programming

Problem With Page Redirect - Help me out with this problem...

ashish_m_k
hey ppl, i just wanted a little help...i designed this website, but i want that if i click on certain link, it should open new page for few seconds and then browser should automatically redirect me to some other page....i tried this with header() function but i couldnt do the wait n redirect part, ...

so somebody plz help....
-thanx in advance!

Notice from jlhaslip:

Thanks Avalon, topic changed.

Comment/Reply (w/o sign-up)

Avalon
The simplest way to do this is to use a <META> tag in between the <HEAD> tags of your document. Here's an example...

CODE
<meta http-equiv="refresh" content="5;url=http://www.mysite.com/nextpage.html">

The value for 'content' is the time in seconds that want the original page to be displayed, the example shows 5 seconds. The value for 'url' is the page you want to redirect to.

Hope that helps.

[END NOTE] When posting your topics you should try to make your subject more descriptive. A better topic for this post would have been "Problem with page redirect, please help". Moderators can sometimes apply a warning for using a subject topic like the one you have used. Just some friendly advice. smile.gif

Comment/Reply (w/o sign-up)

DeveloperX
I use Header php-function for redirection in me pages!

Code like
CODE

<meta http-equiv="refresh" content="5;url=http://www.mysite.com/nextpage.html">
can be stopped by Escape button pressing!!!

About php function - Header

The 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.

CODE

<?php

header("Location: http://www.example.com/"); /* Redirect browser */

/* Make sure that code below does not get executed when we redirect. */
exit;
?>  



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:

CODE


<?php
header("Location: http://" . $_SERVER['HTTP_HOST']
                    . rtrim(dirname($_SERVER['PHP_SELF']), '/\\')
                    . "/" . $relative_url);
?>  



Note: Session ID is not passed with Location header even if session.use_trans_sid is enabled.
It must by passed manually using SID constant.

View full description about Header function at http://php.rinet.ru/manual/ru/function.header.php with some examples.

 

 

 


Comment/Reply (w/o sign-up)

Avalon
@DeveloperX
Does the header() function provide him with the delay he wants? He said he already tried using the header() function but couldn't get it to put a delay in before it redirected. Is there a delay type function in PHP that can be combined with the header() function, something like the javascript timeout() function perhaps? I don't know enough about PHP to answer that question.

Comment/Reply (w/o sign-up)

DeveloperX
@Avalon

Guys! Please seeee my next source code example!
CODE

<?php

//For Ex. I want wait 2 seconds

$sec0=2;//delay
$sec1=date('s');//current server second
$sec2=-1;//for first cycle begin
while($sec2<$sec1+$sec0){$sec2=date('s');}

header("Location: http://www.example.com/"); /* Redirect browser */

exit;

?>  



You may check this script! Very cool! It's my coolest idea...

Comment/Reply (w/o sign-up)

Avalon
QUOTE(DeveloperX @ Jan 10 2006, 09:38 PM)
You may check this script! Very cool! It's my coolest idea...
*


Very nicely done, that should solve his wait problem. I have to agree with you, it's simple and very cool. smile.gif

Comment/Reply (w/o sign-up)

DeveloperX
QUOTE
Very nicely done, that should solve his wait problem. I have to agree with you, it's simple and very cool


One moment please,
You must check "MAX TIME EXECUTION" on your server php-configuration!
Usefully it equal 30 seconds!
But some hosting providers set this parameter for more 30 secs!!!

Comment/Reply (w/o sign-up)

FeedBacker
I like the script since it works, but you need to be able to write to the document.
I'd like to be able to say

"Thanks for registering. Please wait while the page redirects you" or something.

-nate

[note=Approved by BH][/note]

Comment/Reply (w/o sign-up)

iGuest-Ratnesh Kumar
Protected Sub LinkBack_Click(ByVal sender As Object, ByVal e As System.EventArgs)
'Using Page parameters for Back Navigation

If Not Request.Params("ID") Is Nothing Then
Response.Redirect("ExpertsGallery.Aspx")
Else
'String url contains aspx page name from page parameter "URL"
Dim url As String = Request.QueryString("URL")
Response.Redirect(url.ToString())
End If
End Sub

In this code else block dosent work

-reply by Ratnesh Kumar

Comment/Reply (w/o sign-up)

(G)Steve
HTML redirect
Problem With Page Redirect

I hope I can explain this. I have a site with an inline frame. In the inline frame I have it calling a page to logon. I want it to redirect the users to a new page in the members directory. The problem I have is the redirect loads into the same frame. I need a page refresh to the new page. I don't want it to open another page, just reload the new page on the browser page thats already open.

-question by Steve

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)


Searching Video's for problem, page, redirect, problem
See Also,
advertisement


Problem With Page Redirect - Help me out with this problem...

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com