Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

redirection?

Posted on 2001-06-10
5
Medium Priority
?
222 Views
Last Modified: 2006-11-17
how to refirect control to other html page or other php script?
0
Comment
Question by:zastava101
5 Comments
 
LVL 3

Accepted Solution

by:
superschlonz earned 104 total points
ID: 6174859
I thought I have seen a PHP function which does what you want but I can't find
it anymore. So I wrote a little function which should do it:

<?php
function httpPassthru( $host, $port, $file )
{
     if( $port == "" )
     {
          $port = 80;
     }
     $sock = fsockopen( $host, $port );
     if( !$sock )
     {
          return -1;
     }
     fwrite( $sock, "GET " . $file . " HTTP/1.0\r\n" );
     fwrite( $sock, "User-Agent: PHP\r\n" );
     fwrite( $sock, "Connection: close\r\n" );
     fwrite( $sock, "Host: " . $host . ":" . $port . "\r\n" );
     fwrite( $sock, "\r\n" );
     $line = fgets( $sock, 1000 );
     while( $line != "\r\n" )
     {
          $line = fgets( $sock, 1000 );
     }
     fpassthru( $sock );
}
httpPassthru( "www.linux.org", 80, "/" );
?>

But some links can be broken if you redirect a page like this.
0
 
LVL 4

Expert Comment

by:ykf2000
ID: 6175029
hi try this:


<?
    header("Location: another_page.php");
?>
0
 
LVL 1

Expert Comment

by:fajr_n
ID: 6175666
you all above is right.
But if you need the currnet page not in history, the script can see below.

<?
function redirect($target)
{
  header ("Cache-Control: no-cache, must-revalidate");
  header ("Pragma: no-cache");
  header ("Location: $target");
}
?>

$target is your target file or target url

Goodluck
0
 
LVL 1

Expert Comment

by:Rajko
ID: 6195507
<?
header("Location: another_page.php");
exit;
?>

exit - stopped the follow code.
0
 

Expert Comment

by:meetyg
ID: 6200016
Yup, thats the way to do it:

<?
header("Location: http://www.mysite.com");
exit;
?>

but the location doesn't have to be a full URL, it can be any valid URL.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

879 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question