Dashboard Temp Share Shortlinks Frames API

HTMLify

signup.php
Views: 170 | Author: djdj
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
// session_start();
//     if(isset($_SESSION['loggedin']) || $_SESSION['loggedin'] == true){
//         header('location:welcome.php');
//         exit;
//     }
$url = false;
$pass = false;
$insert = false;
$exists = false;
$duplicate = false;
$uduplicate = false;
$eduplicate = false;

    include 'db.php';
    if($_SERVER['REQUEST_METHOD'] == 'POST'){
        $username  = $_POST['username'] ;
        $email     = $_POST['email'];
        $password  = $_POST['password'];
        $cpassword = $_POST['cpassword'];

        //for checking the username already exits or not 
            $sql1 = "SELECT * FROM `ram` WHERE `username` = '$username' ";
            $result1 = mysqli_query($conn, $sql1);
            $num1 = mysqli_num_rows($result1);
            if($num1 > 0){
                $duplicate = true;
                $uduplicate = true;
            }
        
        //for checking the email already exits or not 
            $sql2 = "SELECT * FROM `ram` WHERE `email` = '$email' ";
            $result2 = mysqli_query($conn, $sql2);
            $num2 = mysqli_num_rows($result2);
            if($num2 > 0){
                $duplicate = true;
                $eduplicate = true;
            }

            //checking the password are equal to the confirm password or not  
            if($password == $cpassword){
                if(!$duplicate){ // if username / email are not exits so insert the data in the table 
                    $hash = password_hash($password, PASSWORD_DEFAULT);
                    $sql = "INSERT INTO `ram` (`username`, `email`, `password`, `datetime`) VALUES('$username', '$email', '$hash', current_timestamp() )";
                    $result = mysqli_query($conn, $sql);
                    if($result){
                        $insert = true;                }
                }
            }
            else{
               $pass = true;
            }
    }
?>

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">

    <title>Register</title>
  </head>
  <body>
    <?php
        include 'nav.php';
        if($insert){
            echo '
            <div class="alert alert-success alert-dismissible fade show" role="alert">
                <strong>Success!!</strong> Your account is created, You can Login In.
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                  <span aria-hidden="true">&times;</span>
                </button>
            </div>
            ';
            $url = true;
        }
        if($pass){
            echo '
            <div class="alert alert-warning alert-dismissible fade show" role="alert">
                <strong>Error!!</strong>Password does not match.
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>';
        }
    
        if($uduplicate){
            echo '
                <div class="alert alert-warning alert-dismissible fade show" role="alert">
                    <strong>Username already exists</strong>
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                    </button>
                </div> 
            ';
        }

        if($eduplicate){
            echo '
                <div class="alert alert-warning alert-dismissible fade show" role="alert">
                    <strong>Email already exists</strong>
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                    </button>
                </div> 
            ';
        }
        
    ?>
    <div class="container mt-5">
        <h1 class="text-center">Registration</h1>
        <form method="POST" action="">
            <div class="form-group mt-3">
                <label for="username">Username</label>
                <input type="text" class="form-control" id="username" name="username" placeholder="Enter your username" aria-describedby="emailHelp" required>
            </div>
            <div class="form-group">
                <label for="email">Email address</label>
                <input type="email" class="form-control" id="email" name="email" placeholder="Enter your mail" aria-describedby="emailHelp" required>
                <small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
            </div>
            <div class="form-group">
                <label for="password">Password</label>
                <input type="password" class="form-control" id="password" name="password" placeholder="Enter your password" required>
            </div>
            <div class="form-group">
                <label for="cpassword">Confirm Password</label>
                <input type="password" class="form-control" id="cpassword" name="cpassword" placeholder="Confirm your Password" required>
                <small id="emailHelp" class="form-text text-muted">Make sure type the same password.</small>
            </div>
            <!-- <div class="form-group form-check">
                <input type="checkbox" class="form-check-input" id="exampleCheck1">
                <label class="form-check-label" for="exampleCheck1">Check me out</label>
            </div> -->
            <button type="submit" class="btn btn-primary col-md-6">Sign Up</button>
        </form>
    </div>
    <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
  </body>
</html>