Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("include/dbconnect.php");
- session_start();
- if (isset($_POST["username"]) && isset($_POST["email"]) && isset($_POST["password"]) && isset($_POST["confirmpass"])) {
- $username = $conn->escape_string($_POST["username"]);
- $password = $conn->escape_string(password_hash($_POST["password"], PASSWORD_DEFAULT));
- $confirmpass = $conn->escape_string(password_hash($_POST["confirmpass"], PASSWORD_DEFAULT));
- $email = $conn->escape_string($_POST["email"]);
- $ip = $_SERVER["REMOTE_ADDR"];
- if ($_POST["password"] != $_POST["confirmpass"]) {
- $error = "Confirm password is not equal to the password";
- }else {
- $sql = "SELECT * FROM users WHERE email='$email'";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- $error = "Email already exists";
- }else{
- $sql1 = "SELECT * FROM users WHERE username='$username'";
- $result1 = $conn->query($sql1);
- if ($result1->num_rows > 0) {
- $error = "Username already registered.";
- }
- else {
- $sql2 = "INSERT INTO users (username, email, password, confirmpassword, ip)
- VALUES ('$username', '$email', '$password', '$confirmpass', '$ip')";
- if ($conn->query($sql2)) {
- header("Location: login.php");
- }
- else {
- $error = mysqli_error($conn);
- }
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement