Hello World! Here I did it like in a video tutorial, and still I was mistaken somewhere once it displays this error:

Warning: Cannot modify header information - headers already by (output started at Z: \ home \ dimmetrius.name \ www \ includes \ overall \ header.php: 3) in Z: \ home \ dimmetrius.name \ www \ register. php on line 52

So, here's what happened:

if(isset($_GET['success']) && empty($_GET['success'])) { echo 'Регистрация успешно завершена'; } 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); } } 

Where, header('Location: register.php?success'); everything seems to be written correctly, but somewhere the title starts! This is the file, includes\overall\header.php :

 <!doctype html> <html> <?php include 'includes/head.php'; ?> <body> <?php include 'includes/header.php'; ?> <div id="container"> <?php include 'includes/aside.php'; ?> 

Maybe I'm blind, but I do not see any title here!

Here is the function, register_user ($ register_data); which registers users:

 function register_user($register_data) { array_walk($register_data, 'array_sanitize'); $register_data['password'] = md5($register_data['password']); $fields = '`' . implode('`, `', array_keys($register_data)) . '`'; $data = '\'' . implode('\', \'', $register_data) . '\''; mysql_query("INSERT INTO `users` ($fields) VALUES ($data)"); } 

Here, array_walk ($ register_data, 'array_sanitize');

 function array_sanitize(&$item) { $item = mysql_real_escape_string($item); } 

Where can there be a mistake?

  • Put in place of header (); Javascript echo '<script type = "text / javascript"> document.location.replace ("register.php? Success"); </ script>'; Javascript works fine, but why header (); does not want to work? And gives an unpleasant mistake, if I did not put extra spaces, and extra characters too. Everything is written in utf-8 (without BOM). Does anyone have any thoughts on this? - Gauga
  • four
    Headers must be sent before the first output command. The first output command you have is <!doctype html> . Read the documentation carefully. - Indifferent

0