+ -
当前位置:首页 → 问答吧 → 下面程序为什么不能进行重定向????

下面程序为什么不能进行重定向????

时间:2011-05-05

来源:互联网

下面的程序为什么不能进行重定向:
xialalist2.php

<?php
if (!isset($_POST["send"]))   {?>

<form method="post" action="xialalist2.php">
         <input type="hidden" name="send" value="ture">
   <select name="myselect" size="1" >
      <option value="http://cn.yahoo.com/">雅虎</option>
      <option value="http://www.google.com.hk/">谷歌</option>  
      <option value="http://www.baidu.com">百度</option>
   </select>
    <input type="submit" value="GO!">
</form>
<?php }
else {
        $URL=$_POST["myselect"];
    header("Location:myselect");
}
?>


但如果是写在下面两个文件中的话,却是可以的:
文件一:xialalist.php:

<form method="post" action="redirect.php">
   <select name="myselect" size="1" >
      <option value="http://cn.yahoo.com/">雅虎</option>
      <option value="http://www.google.com.hk/">谷歌</option>  
      <option value="http://www.baidu.com">百度</option>
   </select>
    <input type="submit" value="GO!">
</form>

文件二: redirect.php

<?php
$URL=$_POST["myselect"];
header("Location:$URL");
?>

麻烦路过的高手帮忙看一下      不胜感激!!!    难道是那个if    else   语句用错了吗???改怎样改能在一个文件中显示呢?????

作者: hb任逍遥   发布时间: 2011-05-05

来过。。。

作者: liutong   发布时间: 2011-05-05