doumao1519 2017-02-13 06: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-13 06: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条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!