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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?