Untitled

mail@pastecode.io avatar
unknown
php
4 years ago
1.8 kB
3
Indexable
Never
 $id = $db->mysql_num_rows($check_username)+1;
        $post_email = $db->real_escape_string(trim(filter($_POST['email'])));
        $post_username = $db->real_escape_string(trim(filter($_POST['username'])));
        $post_password = $db->real_escape_string(trim(filter($_POST['password'])));
        $post_cpassword = $db->real_escape_string(trim(filter($_POST['cpassword'])));
        if (empty($post_email) || empty($post_username) || empty($post_password) || empty($post_cpassword)) {
            $msg_type = "error";
            $msg_content = "Mohon mengisi semua input.";
        } else if ($post_cpassword <> $post_password) {
            $msg_type = "error";
            $msg_content = "Konfirmasi Password tidak sesuai.";
        } else if (isset($_COOKIE['register'])) {
            $msg_type = "error";
            $msg_content = "Maaf, Perangkat anda sudah tidak dapat membuat akun lagi.";
        } else {
            $password = password_hash($post_password, PASSWORD_BCRYPT);
            $check_username = $db->query("SELECT * FROM users WHERE username = '$post_username'");
            $check_email = $db->query("SELECT * FROM users WHERE email = '$post_email'");
            if (mysqli_num_rows($check_username) == 1 || mysqli_num_rows($check_email) == 1) {
                $msg_type = "error";
                $msg_content = "Username / E-Mail sudah terdaftar.";
            } else {
                $insert = $db->query("INSERT INTO users VALUES ('', '$id', $post_username', '$password', '$post_email', '0', 'Member', '$date', 'Active', '$api_key', 'website')");
                if ($insert == false) {
                    $msg_type = "error";
                    $msg_content = "Terjadi kesalahan yang tidak diinginkan.";
                } else {