无法重定向到下一页 [英] Not able to redirect to next page

查看:210
本文介绍了无法重定向到下一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Win XP os和XAMPP。我使用eclipse作为编辑器。在Eclipes中,我无法重定向下一页,所以现在我安装了Zend Development Environment。

I am using Win XP os and XAMPP. I was using eclipse as the editor. In Eclipes I was not able to redirect next page so now I have installed Zend Development Environment.

现在我也遇到了同样的问题。

Now also I am getting the same problem.

我的代码是

HomePage.php

HomePage.php

<html>
<body>
<form name="Form1" id="FormId" action="Welcome.php" method="post">
    name : <input type="text" name="txtName">
    Phone Number : <input type="text" name="txtPnum">
    <input type="submit" name="SubmitIt" value="Submit It">     
</form>
</body>
</html>


And Welcome.php is

<?php
    ob_start(); 
    session_start();    
    if(!($_SESSION['UName']))
    {
        $_SESSION['UName']=$_POST['txtName'];
    }
    if(!($_SESSION['Ph Num']))
    {
        $_SESSION['Ph Num']=$_POST['txtPnum'];
    }
?>
<html>
<body>
Welcome <?php   
    if(isset($_SESSION['UName']))
    {
        echo  $_SESSION['UName'];
    }
    else
    {
        echo "Session not set<br/>";    
        echo "{$_SESSION['UName']}";        
        echo "The session contains <br>";
        print_r($_SESSION);
    }           
    ?>
</body>
</html>

在浏览器中可以正常工作(重定向到下一页),但不能在调试模式下工作。

Its working fine (redirecting to next page) in the Browser but its not working in the debug mode. Both in Eclipse and Zend Development Environment.

不是显示下一页的内容,而是显示页面名称。(在我的示例中为welcome.php)。

Instead of show the content of the next page, it showing the page name.(Welcome.php in my example).

我是否需要安装其他任何额外的软件或自己编写的代码...。出什么问题了。

Should I need to install any other extra softwares or code itself worng.... Whats the problem. Please suggest me.

谢谢....!

推荐答案

应该对哪个部分进行重定向,我看不到任何标题('Location:redirect.php')或其他东西

which part is supposed to make a redirection, i don't see any header('Location: redirect.php') or something

以及为什么要使用ob_start ()在这里。

and why do you use ob_start() here .

您没有释放输出缓冲区add ob_get_clean();最终

you didnt release the output buffer add ob_get_clean(); in the end

<?php
    ob_start(); 
    session_start();    
    if(!($_SESSION['UName']))
    {
        $_SESSION['UName']=$_POST['txtName'];
    }
    if(!($_SESSION['Ph Num']))
    {
        $_SESSION['Ph Num']=$_POST['txtPnum'];
    }
    ob_end_flush();
?>
<html>
<body>
Welcome <?php   
    if(isset($_SESSION['UName']))
    {
        echo  $_SESSION['UName'];
    }
    else
    {
        echo "Session not set<br/>";    
        echo "{$_SESSION['UName']}";        
        echo "The session contains <br>";
        print_r($_SESSION);
    }           
    ?>
</body>
</html>

这篇关于无法重定向到下一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆