Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $host = "localhost";
- $user = "globalty_trans";
- $password = "transport2019";
- $name = "globalty_tranport";
- try{
- $con = new mysqli($host, $user, $password,$name);
- if($con->connect_error) {
- die("error " . $con->connect_error);
- }
- }catch(Exception $e){}
- if(isset($_POST['insert'])){
- $fullName=$_POST['fn'];
- $email=$_POST['em'];
- $password=$_POST['pas'];
- $pasHash = password_hash($password, PASSWORD_BCRYPT,array(cost <= 12));
- $check = mysqli_prepare($con, "SELECT * FROM users WHERE username = ?");
- if ($check) {
- $check->bind_param("s", $email);
- $check->execute();
- $result = $check->get_result();
- $num_of_rows = $result->num_rows;
- if($num_of_rows == 0){
- try{
- $insert = mysqli_prepare($con, "INSERT INTO users (fullname,username,password) VALUES (?,?,?)");
- $insert->bind_param("sss", $fullName,$email, $pasHash);
- $insert->execute();
- echo "0";
- }catch(Exception $e){
- echo "1";
- }
- }
- else{
- echo "2";
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement