This question has already been answered:

<?php include("../bd.php"); if(isset($_POST['submit'])) { $user = htmlspecialchars(trim($_POST['user'])); $family = htmlspecialchars(trim($_POST['family'])); $email = htmlspecialchars(trim($_POST['email'])); $login = htmlspecialchars(trim($_POST['login'])); $password = htmlspecialchars(trim($_POST['password'])); $form = array($user,$family,$email,$login,$password); foreach($form as $s => $value){ if($value == ""){ echo 'Заполните поле'; exit; } } $db = connect(); $res = mysql_query("SELECT `login` FROM `users` WHERE `login` = '$login' "); $data = mysql_fetch_array($res); if(!empty($data['login'])){ die("Такой логин уже существует!"); } $password = hash('sha1', $password.$login); $query = "INSERT INTO `users` (`user`,`family`,`email`,`login`,`pass`) VALUES('$user','$family','$email','$login','$password') "; $result = mysql_query($query); if($result == true){ header("Location: login.php");} // }else{ // echo "Error! ----> ". mysql_error(); // } } ?> 

Reported as a duplicate by VenZell , ReinRaus , Ipatiev , Community Spirit 23 May '16 at 14:12 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

    1 answer 1

    header, traditionally, you can only send to any output.