Forum Gündemi:


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

*
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:40 PM
Kodlar:
PHP Kod:
require_once('config.php');
if(isset(
$_POST['actionLogin'])){
    $user_nickname strip_tags(trim($_POST['user_nickname']));
    $user_password sha1(strip_tags(trim($_POST['user_password'])));
    //if sent values are empty
    if(empty($user_nickname) || empty($user_password)){
        echo "space";
    }else{
        //We are capturing user information
        $loginCheckUserExists $dbh->prepare("SELECT * FROM user WHERE user_nickname = :user_nickname");
        $loginCheckUserExists->execute(array(
            ":user_nickname" => $user_nickname
        
));
        $loginCheckUserExistsRow $loginCheckUserExists->fetch(PDO::FETCH_ASSOC);
        //If the user is available
        if($loginCheckUserExists->rowCount() > 0){
            //If the username and password are correct
            if($user_nickname == $loginCheckUserExistsRow['user_nickname'] && $user_password == $loginCheckUserExistsRow['user_password']){
                //User status
                //If the user is inactive
                if($loginCheckUserExistsRow['user_status'] == "0"){
                    echo "banned_or_disabled";
                //If user status is active
                }else if($loginCheckUserExistsRow['user_status'] == "1"){
                    $_SESSION['user_nickname'] = $user_nickname;
                    $_SESSION['user_session'] = true;
                    echo "success";
                //If the user status is pending (Mail Activation...)
                }else if($loginCheckUserExistsRow['user_status'] == "2"){
                    echo "awaiting_mail_activation";
                }
            }else{
                //If the username and password are incorrect
                echo "username_or_password_false";
            }
        }else{
            //If there is no such user
            echo "not_exists";
        }
    }

[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