PHP使用isset($_GET)形成成功消息


PHP form success message using isset($_GET)

我正在关注youtube上的php登录和注册教程,该教程迄今为止一直非常有用。

第1部分http://www.youtube.com/watch?v=axE55ZKMso4

第2部分http://www.youtube.com/watch?v=5A50qmC7wFo(卡在这里(

我已经建立了我的表单并创建了一些错误报告,但当我试图显示一条成功的注册消息时,问题就出现了。该页面似乎没有重定向到指定的页面,并且我的错误帖子部分下的任何内容在注册后都会消失。

除了信息之外,其他方面都在发挥作用,我一直在严格遵循他,但我实现了自己的设计。请帮忙。PS。第一次在这里发帖。

这是我所有错误后声明的代码。

      <?php
      if (isset($_GET['success']) && empty($_GET['success'])) {
          echo '<font color="#FF0033">Registration Message here</font> ';
      } else {
          if (empty($_POST) === false && empty($errors) === true)  {
              $register_data = array(
              'username'     => $_POST['username'],
              'password'     => $_POST['password'],
              'first_name'   => $_POST['first_name'],
              'last_name'    => $_POST['last_name'],
              'email'    => $_POST['email']
              );
             register_user($register_data);
             header('Location: register.php?success');
             exit();
            } else if (empty($errors) === false) {
            echo output_errors($errors);
            }
      }
      ?>

这下面的所有内容,包括表单和其他方面的内容,都存在于着陆时,但一旦激活注册按钮,这里的所有内容都会消失。

我认为"header('Location:register.php?success'(;".可能有问题

此外,当我通过本地主机强制../rootfolder/register.php/success时,我会得到一个未格式化的页面?就像它失去了所有的CSS和Javascript一样?

您认为exit()的作用是什么?

header('Location: register.php?success');

应该将浏览器重定向到register.php-script。如果没有,则很可能在头调用之前有任何输出。标头应在任何其他输出之前发送。

我目前正在关注本教程,有人在视频的评论中发帖放ob_start((;在包含"core/init.php"之前;它奏效了。

<?php
ob_start();
include "core/init.php";