I Need A Re-direction Script - I need a script...

Pages: 1, 2
free web hosting

Read Latest Entries..: (Post #12) by Quatrux on Apr 9 2006, 04:26 AM. (Line Breaks Removed)
QUOTE(Houdini @ Apr 9 2006, 03:12 AM) This is not true, what is true is that there can be no output (to a browser) no HTML at all, I use it after processing a form and entering new data into the database and then sending the user either to a welcome page or another page immediately after filling in the fields. The header() function may be used anywhere in the script so long as you place i... read more.
Read the FIRST post of this Topic. - Express your Opinion! Contribute Knowledge :-).

Free Web Hosting > Computers & Tech > Programming > Scripting

I Need A Re-direction Script - I need a script...

imajin8shun
I'm looking for a re-direction script to re-direct you form one page to another automatically within the space of a few seconds. Like say I type www.sitename.com I want the script to activate straight away or within a few seconds to take them to like ww.sitename.com/file.php.

I've looked through good-tutorials, phpfreaks, kirupa, html-goodies, and I couldn't find a script. can anyone help. HTML, PHP, JavaScripts are the kind I'm looking for, prefeably html or php.

Note: I didn't know where to post this seeing as I'm looking for one of three different types of scripts.

Reply

warbird
That's very easy, without any scripting language, just in HTML.

put this tag in the header of your page:

CODE

<head>
   <meta http-equiv="refresh" content="6; // The time before re-direction in seconds
url=http://www.spele.nl/spele//yetisports1.swf"> // The link to re-direct to
</head>

Reply

jet
There are many simple codes out there to redirect, and Dynamic Drive (DHTML Scripts) offers this more complicated one:

CODE

<script>

//Browser redirect Script- © Dynamic Drive (www.dynamicdrive.com)
//For full source code, 100's more DHTML scripts, and Terms Of Use,
//visit dynamicdrive.com

var browser_type=navigator.appName
var browser_version=parseInt(navigator.appVersion)

//if NS 6
if (browser_type=="Netscape"&&browser_version>=5)
window.location.replace("PAGE URL FOR SOMEONE USING NETSCAPE 4")
//if IE 4+
else if (browser_type=="Microsoft Internet Explorer"&&browser_version>=4)
window.location.replace("PAGE URL FOR SOMEONE USING INTERNET EXPLORER")
//if NS4+
else if (browser_type=="Netscape"&&browser_version>=4)
window.location.replace("PAGE URL FOR SOMEONE USING NETSCAPE 6+")
//Default goto page (NOT NS 4+ and NOT IE 4+)
else
window.location="http://www.dynamicdrive.com"
</script>


As you can see, that enables people to go to different places depending on their browser.. Not entirely necessary, of course, but nothing ever is. And never use a blank page to redirect - always put a "redirecting in x seconds, click here if your browser is being disobedient" link.

 

 

 


Reply

whistle

CODE

<?php

header('location: http://www.astahost.com');

?>

This is a script for url forwarding given by someone in a thread of the forum "PHP".

You said you need the code in PHP. I hope this can help you.

Reply

Hercco
QUOTE(whistle @ Jul 28 2005, 07:14 PM)
CODE

<?php

header('location: [url=http://www.astahost.com');]http://www.astahost.com');[/url]

?>

*




This is the way to do it. Some browsers and firewalls block META refreshes and some people don't have javascript turned on, but a redirect done by HTTP document moved works always. Its the professional, stylish and also easiest way to do it.

Reply

whistle
QUOTE(Hercco @ Aug 14 2005, 09:28 PM)
This is the way to do it. Some browsers and firewalls block META refreshes and some people don't have javascript turned on, but a redirect done by HTTP document moved works always. Its the professional, stylish and also easiest way to do it.
*



It seems that there is a limitation in that code. No other codes can be placed before the header. If you hope to leand a file first and then to do the redirection, this will dispoint you. For examples, if you hope to put the code <? include "config.php"; ?> before header, it will says header has been sent. The DHTML code would be a better choice if you want your code more flexible.

Reply

saxsux
There is a way to do it from your cPanel.
Rather than waiting, it redirects you straight away.

Under Site Managment, click Manage Redirects (forth down on the right).
The rest is pretty easy to figure out, so I'll leave you to it.

Hope this helps,
saxsux :-)

Reply

finaldesign
Anyway whenever you will need some script first goto www.hotscripts.com and search there, If you are unable to find it there then try here at the forums... cool.gif

Reply

jcguy
It's easy to do redirection by adding a command in htaccess. The htaccess file is a file which a server will look up first before serving a page. Go edit your .htaccess file, usually found in public_html folder and add the following line:

Redirect /page1.html http://www.site.com/file-you-want.html

The page1.html is the page you want to redirect, its position relative from the public_html folder. The address that follow points to the page you want your visitors to be reditrected to.

Reply

TavoxPeru
QUOTE(imajin8shun @ Jul 7 2005, 12:41 AM) *

I'm looking for a re-direction script to re-direct you form one page to another automatically within the space of a few seconds. Like say I type www.sitename.com I want the script to activate straight away or within a few seconds to take them to like ww.sitename.com/file.php.

I've looked through good-tutorials, phpfreaks, kirupa, html-goodies, and I couldn't find a script. can anyone help. HTML, PHP, JavaScripts are the kind I'm looking for, prefeably html or php.

Note: I didn't know where to post this seeing as I'm looking for one of three different types of scripts.


Hi, is very easy, you can do it with html using a meta tag http-equiv=refresh or with php using the header(Location=) function. For example using html you can put this in your head section:

CODE
<meta http-equiv="refresh" content="5; url=file.php">

it will instruct the browser to wait 5 seconds and then redirect to the file.php.

Now, using PHP you have 2 options:
  1. Direct redirection:
    CODE
    <?php
    Header("Location: file.php");
    ?>
  2. With a time interval redirection:
    CODE
    <?php
    // wait 5 seconds then redirect
    Sleep(5);
    Header("Location: file.php");
    ?>

of course there will be other ways to do the same.

best regards,

Reply

Latest Entries

Quatrux
QUOTE(Houdini @ Apr 9 2006, 03:12 AM) *

This is not true, what is true is that there can be no output (to a browser) no HTML at all, I use it after processing a form and entering new data into the database and then sending the user either to a welcome page or another page immediately after filling in the fields. The header() function may be used anywhere in the script so long as you place it somewhere within that script that produces no output, what do you thinkis happening when you fill out the registration data here on this site, you are being redirected with a header, you are not clicking any links and somehow that data got placed into a database while you were being sent to the next part of the registration process.


Yes, if you code properly it is easy to use header() and other functions like session_start() and setcookie() which requires that no output would be send before they are called, as a matter of fact it is best to output your site at the end of script after everything has been execute, but an alternative to this is to use output buffering, earlier a lot of whom did not use it, because they were "afraid" that something might be wrong and were avoiding ob_start() function, but a lot of whom saw the potential to use it and saw that everything works clean, I use it myself and now I usually don't have problems with it, but you need to get used to it and use it properly too. wink.gif

and sometimes using the Refresh header, which brakes the back button is good, especially if you want to break it and that users could not browse back to them and you can use it not only by meta tags, it is the same with header() function:

CODE

<?php
header("Refresh: 0; URL=\"file.php\"");
?>


And the code can continue if you want it to parse something, just add some more seconds for the header, the browser will redirect. But remember, that Refresh header is not the Standard of HTTP, Most browsers just support it and thats all, so be careful when using it, the alternative is to use flush() with sleep() but this is crazy. wink.gif

Reply

mastercomputers
The best way to do it is to send the redirection status code for the HTTP/1.1 protocol (3XX) which automatically gets sent when using the PHP header('Location: someaddress/page') function, unless a status code has already been sent. The meta refresh is not a good idea, because it breaks the back button.

Status code 301 for permanent redirect or Status code 302 for temporary.

CODE
<?php
header('Location: http://thisaddress.com/page.html');
exit;
?>


Should always make sure to exit too, incase there's code after it that you don't want to process before being redirected. There's other ways to do it too, which requires .htaccess file and URL rewriting or using the redirect derivative but avoid using meta refresh.


Cheers,


MC

Reply


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*

(Maximum characters: 10,000)
You have characters left.

Pages: 1, 2
Recent Queries:-
  1. php header redirect to file different folder - 43.71 hr back. (1)
  2. how to make url re direction - 108.21 hr back. (1)
  3. browser redirect script, in seconds - 110.69 hr back. (1)
  4. script direction - 116.02 hr back. (1)
  5. header(location:file:/// - 175.97 hr back. (1)
  6. ie meta refresh brakes back button - 267.75 hr back. (1)
  7. simple dos script if else - 269.24 hr back. (1)
  8. give direction script - 337.53 hr back. (1)
  9. header ("location: ie - 372.46 hr back. (1)
  10. ww.spele.nl - 52.63 hr back. (4)
  11. window.location.replace(headers - 461.44 hr back. (1)
  12. simple redirect script php after time sleep - 489.55 hr back. (1)
  13. window.location redirect to another page on different folder - 497.38 hr back. (1)
  14. script spele.nl - 515.47 hr back. (1)
Similar Topics

Keywords : direction, script, script

  1. Looking For Script
    need help (5)
  2. Auto-click Script
    (7)
    I wanna know how to make a "auto-click" script in web browser.... i want it to do this: I am on a
    web page...I have 3 options to click....so i want it to click one,after it reloads it waits for 25
    seconds and clicks 2nd,and again waits to reload and that 25 seconds and clicks 3rd option... is it
    possible to create that kind of script?it would be better if it was executable program so u can set
    it where exactly it should click... if you don't understand some of things i said tell me and i
    will "translate" it into English XD....
  3. Script Using Ping To Monitor Network
    (9)
    I want a batch/dos file that will ping certain IP addresses at intervals of say 1 hour. If the IP
    address is not pingable after each hourly checkup, I want it to give some kind of warning. Maybe
    startup a notepad file and indicate the IP address that lost the network connection. I will want to
    improve on this later on, but for now, a simple dos batch file or something similar will do.
    I'm using Windows XP at the office network. Thanks.....
  4. I Need An Affilate Script ,any Suggestions?
    (1)
    It is like i am selling a particular product,i need to promote it through an multilevel affiliate
    program. can u suggest a good affilate script.....
  5. How Can I Create A "number Of Visitors" Script
    (8)
    Sorry, I am rather new on this forum, so I'm not quite sure it's the best place to ask this
    question, maybe a moderator should move my post to a more accurate subforum. However, I really would
    like to have this info. How can I add a counter in my page, counting the people visiting my webpage
    ? Is there a script "ready for use" somewhere on astahost ? Regards Yordan....

    1. Looking for direction, script, script

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for direction, script, script
advertisement




I Need A Re-direction Script - I need a script...



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE