Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

redirection?

Posted on 2001-06-10
5
Medium Priority
?
221 Views
Last Modified: 2006-11-17
how to refirect control to other html page or other php script?
0
Comment
Question by:zastava101
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
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…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

705 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