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条)

报告相同问题?

悬赏问题

  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来