PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php class Register{ /* Публичная функция для реализации регистрации */ public function registration($full_name, $login, $email, $password, $confurm_password){ $password = password_hash($password, PASSWORD_DEFAULT); $confurm_password = password_hash($confurm_password, PASSWORD_DEFAULT); $sql = "SELECT * FROM `users` WHERE `login` = '$login' OR `email` = '$email'"; $dublicate = mysqli_query($this->con, $sql); if(mysqli_num_rows($dublicate) > 0){ return 10; } else{ if($password == $confurm_password){ $sql = "INSERT INTO `users` (`full_name`, `login`, `email`, `password`) VALUES ('$full_name', '$login', '$email', '$password')" ; $query = mysqli_query($this->con, $sql); return 1; } else{ return 100; } } } } $register = new Register(); if(isset($_POST["submit"])){ $result = $register->registration($_POST["full_name"], $_POST["login"], $_POST["email"], $_POST["password"], $_POST["confurm_password"]); if($result == 1){ echo "<script> alert('Registration Successful'); </script>"; } elseif($result == 10){ echo "<script> alert('Username or Email Has Already Taken'); </script>"; } elseif($result == 100){ echo "<script> alert('Password Does Not Match'); </script>"; } }
Show:  
Copy Clear