اذهب إلى المحتوى
  • 0

كيفية عمل التحقق من الأيميل (email verifycation) عن طريق php mysqli html css

Omar Ammora

السؤال

Recommended Posts

  • 0

إن كنت تريد أن يتم التحقق من صحة الإيميل عبر رابط يتم ارساله الى الإيميل المسجل، كل ما عليك فعله هو : 

- اضافة حقلين hash و active (الملف المرفق 1)

active = 0 معناه لم يتم تأكيد الحساب active = 1 تم تأكيد الحساب

- عند التسجيل يتم توليد كود مميز (hash)  يتم تخزينه في القاعدة الى جانب active = 0

// توليد هاش عشوائي
$hash = md5( rand(0,999999) );

- تسجيل العضو :

mysql_query("INSERT INTO users (username, password, email, hash) VALUES(
'". mysql_escape_string($name) ."', 
'". mysql_escape_string(md5($password)) ."', 
'". mysql_escape_string($email) ."', 
'". mysql_escape_string($hash) ."') ") or die(mysql_error());

ارسال معلومات التسجيل الى الايميل + رابط التفعيل : 

$to      = $email; 
$subject = 'Signup | Verification'; 
$message = '
 
Thanks for signing up!
Your account has been created, you can login with the following credentials after you have activated your account by pressing the url below.
 
------------------------
Username: '.$name.'
Password: '.$password.'
------------------------
 
Please click this link to activate your account:
http://www.yourwebsite.com/verify.php?email='.$email.'&hash='.$hash.'
 
';
                     
$headers = 'From:noreply@yourwebsite.com' . "\r\n"; 
mail($to, $subject, $message, $headers);

- وهكذا عند الضغط على رابط التأكيد : 

mysql_connect("localhost", "tutorial", "password") or die(mysql_error());
mysql_select_db("registrations") or die(mysql_error());
             
if(isset($_GET['email']) && !empty($_GET['email']) AND isset($_GET['hash']) && !empty($_GET['hash'])){
    // Verify data
    $email = mysql_escape_string($_GET['email']);
    $hash = mysql_escape_string($_GET['hash']); 
                 
    $search = mysql_query("SELECT email, hash, active FROM users WHERE email='".$email."' AND hash='".$hash."' AND active='0'") or die(mysql_error()); 
    $match  = mysql_num_rows($search);
                 
    if($match > 0){
        mysql_query("UPDATE users SET active='1' WHERE email='".$email."' AND hash='".$hash."' AND active='0'") or die(mysql_error());
        echo 'تم تفعيل حسابك بنجاح';
    }else{
        echo 'خطأ : لم يتم تفعيل حسابك';
    }
                 
}else{
    echo 'خطأ ...';
}

 

db.jpg

رابط هذا التعليق
شارك على الشبكات الإجتماعية

  • 0
بتاريخ 1 ساعة قال Ahmed Charafeddine Meftah:

إن كنت تريد أن يتم التحقق من صحة الإيميل عبر رابط يتم ارساله الى الإيميل المسجل، كل ما عليك فعله هو : 

- اضافة حقلين hash و active (الملف المرفق 1)

active = 0 معناه لم يتم تأكيد الحساب active = 1 تم تأكيد الحساب

- عند التسجيل يتم توليد كود مميز (hash)  يتم تخزينه في القاعدة الى جانب active = 0


// توليد هاش عشوائي
$hash = md5( rand(0,999999) );

- تسجيل العضو :


mysql_query("INSERT INTO users (username, password, email, hash) VALUES(
'". mysql_escape_string($name) ."', 
'". mysql_escape_string(md5($password)) ."', 
'". mysql_escape_string($email) ."', 
'". mysql_escape_string($hash) ."') ") or die(mysql_error());

ارسال معلومات التسجيل الى الايميل + رابط التفعيل : 


$to      = $email; 
$subject = 'Signup | Verification'; 
$message = '
 
Thanks for signing up!
Your account has been created, you can login with the following credentials after you have activated your account by pressing the url below.
 
------------------------
Username: '.$name.'
Password: '.$password.'
------------------------
 
Please click this link to activate your account:
http://www.yourwebsite.com/verify.php?email='.$email.'&hash='.$hash.'
 
';
                     
$headers = 'From:noreply@yourwebsite.com' . "\r\n"; 
mail($to, $subject, $message, $headers);

- وهكذا عند الضغط على رابط التأكيد : 


mysql_connect("localhost", "tutorial", "password") or die(mysql_error());
mysql_select_db("registrations") or die(mysql_error());
             
if(isset($_GET['email']) && !empty($_GET['email']) AND isset($_GET['hash']) && !empty($_GET['hash'])){
    // Verify data
    $email = mysql_escape_string($_GET['email']);
    $hash = mysql_escape_string($_GET['hash']); 
                 
    $search = mysql_query("SELECT email, hash, active FROM users WHERE email='".$email."' AND hash='".$hash."' AND active='0'") or die(mysql_error()); 
    $match  = mysql_num_rows($search);
                 
    if($match > 0){
        mysql_query("UPDATE users SET active='1' WHERE email='".$email."' AND hash='".$hash."' AND active='0'") or die(mysql_error());
        echo 'تم تفعيل حسابك بنجاح';
    }else{
        echo 'خطأ : لم يتم تفعيل حسابك';
    }
                 
}else{
    echo 'خطأ ...';
}

 

db.jpg

شكرا جزيلا سأجرب الطريقة 

 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

  • 0
بتاريخ 19 ساعات قال Ahmed Charafeddine Meftah:

إن كنت تريد أن يتم التحقق من صحة الإيميل عبر رابط يتم ارساله الى الإيميل المسجل، كل ما عليك فعله هو : 

- اضافة حقلين hash و active (الملف المرفق 1)

active = 0 معناه لم يتم تأكيد الحساب active = 1 تم تأكيد الحساب

- عند التسجيل يتم توليد كود مميز (hash)  يتم تخزينه في القاعدة الى جانب active = 0


// توليد هاش عشوائي
$hash = md5( rand(0,999999) );

- تسجيل العضو :


mysql_query("INSERT INTO users (username, password, email, hash) VALUES(
'". mysql_escape_string($name) ."', 
'". mysql_escape_string(md5($password)) ."', 
'". mysql_escape_string($email) ."', 
'". mysql_escape_string($hash) ."') ") or die(mysql_error());

ارسال معلومات التسجيل الى الايميل + رابط التفعيل : 


$to      = $email; 
$subject = 'Signup | Verification'; 
$message = '
 
Thanks for signing up!
Your account has been created, you can login with the following credentials after you have activated your account by pressing the url below.
 
------------------------
Username: '.$name.'
Password: '.$password.'
------------------------
 
Please click this link to activate your account:
http://www.yourwebsite.com/verify.php?email='.$email.'&hash='.$hash.'
 
';
                     
$headers = 'From:noreply@yourwebsite.com' . "\r\n"; 
mail($to, $subject, $message, $headers);

- وهكذا عند الضغط على رابط التأكيد : 


mysql_connect("localhost", "tutorial", "password") or die(mysql_error());
mysql_select_db("registrations") or die(mysql_error());
             
if(isset($_GET['email']) && !empty($_GET['email']) AND isset($_GET['hash']) && !empty($_GET['hash'])){
    // Verify data
    $email = mysql_escape_string($_GET['email']);
    $hash = mysql_escape_string($_GET['hash']); 
                 
    $search = mysql_query("SELECT email, hash, active FROM users WHERE email='".$email."' AND hash='".$hash."' AND active='0'") or die(mysql_error()); 
    $match  = mysql_num_rows($search);
                 
    if($match > 0){
        mysql_query("UPDATE users SET active='1' WHERE email='".$email."' AND hash='".$hash."' AND active='0'") or die(mysql_error());
        echo 'تم تفعيل حسابك بنجاح';
    }else{
        echo 'خطأ : لم يتم تفعيل حسابك';
    }
                 
}else{
    echo 'خطأ ...';
}

 

db.jpg

عذرا اخي هل اضع كود توليد هاش عشوائي ضمن كود تسجيل عضو او انشأ صفحة واضعه فيها وشكراا....

عذرا اخي هل اضع كود توليد هاش عشوائي ضمن كود تسجيل عضو او انشأ صفحة واضعه فيها وشكراا....

رابط هذا التعليق
شارك على الشبكات الإجتماعية

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...