doupo1865 2018-11-04 19:06
浏览 8
已采纳

PHP和重定向[重复]

This question already has an answer here:

I am fairly new to this site and have a question about a problem that I have recently. How to interact with a page on which we just made a redirection? That is, after validating a form, I would like to be able to redirect the user to the login page and show him a success message such as: Successful registration! But I can not do it.

</div>
  • 写回答

3条回答 默认 最新

  • douli4337 2018-11-04 19:28
    关注

    Not the prettiest solution, but it will work.

    The header function can be used to redirect a user to a page.

    header("Location: myFile.php?message=success"); // success can be changed to fail

    You can then use this code on the destination page to display the message accordingly.

    if(isset($_GET['message'])) {
    
        if($_GET['message'] == 'success') {
            echo 'Registered successfully!';
        } elseif($_GET['message'] == 'fail') {
            echo 'Registration failed.';
        }
    
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器