0

I'm following a php log in and registration tutorial on youtube which has been very helpful until now.

Part 1 http://www.youtube.com/watch?v=axE55ZKMso4

part 2 http://www.youtube.com/watch?v=5A50qmC7wFo (Stuck HERE)

Ive established my form and created some error reports, but the problem comes in when I try to get a successful registration message to appear. The page does not seem to redirect to the specified page and anything under my error post section disappears after registration.

Every other aspect is working except the message, Ive followed him down to the letter, however I implemented my own design. Please help. PS. first time posting here.

Here is my code after all my error post statements.

      <?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);
            }
      }
      ?>

Everything under this, including the form and other aspects of content exist on landing, but as soon as the registration button is activated, all content under here disappears.

I think there may be a problem with "header('Location: register.php?success');".

In addition, when I force ../rootfolder/register.php/success through the local host I get an unstyled page? Like its lost all of the CSS and Javascript ?

4

2 回答 2

0

你觉得有什么exit()作用?

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

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

于 2013-11-02T21:05:58.097 回答
0

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

<?php
ob_start();
include "core/init.php";
于 2015-09-04T16:48:22.167 回答