Advertisement
Guest User

Untitled

a guest
May 23rd, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. <?php
  2. include("../bd.php");
  3.  
  4. if(isset($_POST['submit']))
  5. {
  6.  
  7. $user = htmlspecialchars(trim($_POST['user']));
  8. $family = htmlspecialchars(trim($_POST['family']));
  9. $email = htmlspecialchars(trim($_POST['email']));
  10. $login = htmlspecialchars(trim($_POST['login']));
  11. $password = htmlspecialchars(trim($_POST['password']));
  12.  
  13. $form = array($user,$family,$email,$login,$password);
  14. foreach($form as $s => $value){
  15. if($value == ""){
  16. echo 'Заполните поле';
  17. exit;
  18. }
  19. }
  20.  
  21. $db = connect();
  22.  
  23. $res = mysql_query("SELECT `login` FROM `users` WHERE `login` = '$login' ");
  24. $data = mysql_fetch_array($res);
  25. if(!empty($data['login'])){
  26. die("Такой логин уже существует!");
  27. }
  28.  
  29. $password = hash('sha1', $password.$login);
  30. $query = "INSERT INTO `users` (`user`,`family`,`email`,`login`,`pass`)
  31. VALUES('$user','$family','$email','$login','$password') ";
  32. $result = mysql_query($query);
  33.  
  34. if($result == true){
  35. header("Location: login.php");}
  36. // }else{
  37. // echo "Error! ----> ". mysql_error();
  38. // }
  39. }
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement