doumao1519 2017-02-12 22:24
浏览 68
已采纳

仅在重定向但不使用php键入url时显示页面

I am trying to show a page only when its redirected through submit button.For example.
If the main url is http://www.example.com

 Am having form in `http://wwww.example.com/form.php` and when its submitted its         
 redirected to http://wwww.example.com/success.php

but if the user types http://wwww.example.com/success.php in the browser URL how can I redirect it to form.php if the form is not submitted.

  • 写回答

2条回答 默认 最新

  • dqbr37828 2017-02-12 22:32
    关注

    Please create a SESSION variable on form.php just before redirecting to success.php & check that SESSION variable on success.php. Just like this:

    On form.php

    <?php
    session_start();
    $SESSION['user'] = '$user_name';    //Put your username in this or any value which you want to check on success.php page
    header("Location : http://wwww.example.com/success.php");
    ?>
    

    And now on success.php

    <?php session_start();
    if(!isset($SESSION['user'])){
       header("Location : http://wwww.example.com/form.php");
    }
    
    //Now your success.php code & content
    ?>
    

    Hope, this may be helpful for you.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部