Forum Gündemi:


Konu Başlığı : [PHP] PDO Güvenli Kayıt

*
Bu konu; tarihinde açılmış olup, 0 defa yorumlanmıştır.
Konu Sahibi : oxcakmak
Konuyu Değerlendir
  • 0 Oy - 0 Ortalama
  • 1
  • 2
  • 3
  • 4
  • 5
Çevrimdışı
Back-End Developer
******
105
mesajlar
82
konular
0
(Ticaret Puanı: )
Aug 2019
(Kayıt Tarihi)
#1
08-05-2019, 02:39 PM
Kodlar:
PHP Kod:
require_once('config.php');
if(isset(
$_POST['actionRegister'])){
        $user_nickname strip_tags(trim($_POST['user_nickname']));
        $user_email strip_tags(trim($_POST['user_email']));
        $user_password strip_tags(trim($_POST['user_password']));
        //if sent values are empty
        if(empty($user_nickname) || empty($user_password)){
            echo "space";
        }else{
            //if the user name is less than 5 characters long
            if(strlen($user_nickname) < 5){
                echo "min_five_username";
            }else{
                //if the password is less than 5 characters long
                if(strlen($user_password) < 5){
                    echo "min_five_password";
                }else{
                    $user_password sha1(strip_tags(trim($_POST['user_password'])));
                    //if the e-mail address is equal to the supported service extension
                    //[https://github.com/oxcakmak/PHP-Email-Validate-Validator]
                    if(validateMail($user_email$supportedMails)){
                        $registerCheckUserExists $dbh->prepare("SELECT * FROM user WHERE user_nickname = :user_nickname");
                        $registerCheckUserExists->execute(array(
                            ":user_nickname" => $user_nickname
                        
));
                        $registerCheckUserExistsRow $registerCheckUserExists->fetch(PDO::FETCH_ASSOC);
                        //if the user is present in the system
                        if($registerCheckUserExists->rowCount() > 0){
                            echo "exists";
                        }else{
                            //if the user is not present in the system
                            $insertRegisterUser $dbh->prepare("INSERT INTO user (user_nickname, user_email, user_password, user_address, user_date, user_key) VALUES (:user_nickname, :user_email, :user_password, :user_address, :user_date, :user_key)");
                            $insertRegisterUser->execute(array(
                                ":user_nickname" => $user_nickname
                                ":user_email" => $user_email
                                ":user_password" => $user_password
                                ":user_address" => $newAddress
                                ":user_date" => $newDate,
                                ":user_key" => bin2hex(openssl_random_pseudo_bytes(16))
                            ));
                            echo "success";
                        }
                    }else{
                        echo "unsupported_mail_service";
                    }
                }
            }
        }
    
[Linkleri yalnızca üyeler görüntüleyebilir.Sizde aramıza katılmak ister misiniz? Üye Olmak İçin Buraya Tıklayın.]


Foruma Git:


Görüntüleyenler: 1 Ziyaretçi