المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : شرح طريقة عمل نظام تأكيد البريد الإلكترونى



walid
11-01-2013, بتوقيت غرينيتش 04:43 PM
http://www.dzbatna.com/images/icons/iconrote.gif ط´ط±ط* ط¹ظ…ظ„ ظ†ط¸ط§ظ… طھط£ظƒظٹط¯ ط§ظ„ط¨ط±ظٹط¯ ط§ظ„ط¥ظ„ظƒطھط±ظˆظ†ظ‰ (http://www.dzbatna.com/t2276889/)



بسم الله الرحمن الرحيم

السلام عليكم ورحمة الله وبركاته



درس مفصل اليوم عن طريقة عمل نظام Email Verification

بدايةً ، نقوم بإنشاء ملف PHP جديد ، ونقوم بعمل Function

رمز PHP:

<code style="white-space:nowrap"> <code> <?php
function EmailValidation($email) {
}
?> </code> </code>

ثم نقوم بحذف اي رموز من البريد الإلكترونى عن طريق استخدام الدوال

htmlspecialchars(), stripslashes(), strip_tags()

رمز PHP:

<code style="white-space:nowrap"> <code> <?php
function EmailValidation($email) {
$email = htmlspecialchars(stripslashes(strip_tags($email))) ; //parse unnecessary characters to prevent exploits
}
?> </code> </code>

من ثم سنستخدم eregi من أجل التأكد من صيغة الإيميل

مثال : namehttp://www.dzbatna.com/images/mail.gifdomain.extention

رمز PHP:

<code style="white-space:nowrap"> <code> <?php
function EmailValidation($email) {
$email = htmlspecialchars(stripslashes(strip_tags($email))) ; //parse unnecessary characters to prevent exploits
if ( eregi ( '&#91;a-z||0-9&#93;http://www.dzbatna.com/images/mail.gif&#91;a-z||0-9&#93;.&#91;a-z&#93;', $email ) ) { //checks to make sure the email address is in a valid format



}
}
?> </code> </code>

الآن سنقسم البريد الإلكترونى الى نصفين ، من أجل اللجوء الى خادم السيرفر SERVER الخاص بالدومين الذي بعد http://www.dzbatna.com/images/mail.gif

رمز PHP:

<code style="white-space:nowrap"> <code> <?php
function EmailValidation($email) {
$email = htmlspecialchars(stripslashes(strip_tags($email))) ; //parse unnecessary characters to prevent exploits
if ( eregi ( '&#91;a-z||0-9&#93;http://www.dzbatna.com/images/mail.gif&#91;a-z||0-9&#93;.&#91;a-z&#93;', $email ) ) { //checks to make sure the email address is in a valid format
$domain = explode( "http://www.dzbatna.com/images/mail.gif", $email ); //get the domain name
if ( http://www.dzbatna.com/images/mail.giffsockopen ($domain&#91;1&#93;,80,$errno,$errstr,3)) {
//if the connection can be established, the email address is probabley valid
return true;
}
}
?> </code> </code>

الآن سنكتب بعض الأكواد من أجل إحتمالية أن يكون البريد الإلكترونى غير صحيح
رمز PHP:

<code style="white-space:nowrap"> <code> <?php
function EmailValidation($email) {
$email = htmlspecialchars(stripslashes(strip_tags($email))) ; //parse unnecessary characters to prevent exploits
if ( eregi ( '&#91;a-z||0-9&#93;http://www.dzbatna.com/images/mail.gif&#91;a-z||0-9&#93;.&#91;a-z&#93;', $email ) ) { //checks to make sure the email address is in a valid format
$domain = explode( "http://www.dzbatna.com/images/mail.gif", $email ); //get the domain name
if ( http://www.dzbatna.com/images/mail.giffsockopen ($domain&#91;1&#93;,80,$errno,$errstr,3)) {
//if the connection can be established, the email address is probabley valid
return true;
/*
GENERATE A VERIFICATION EMAIL
*/
} else {
return false; //if a connection cannot be established return false
}
} else {
return false; //if email address is an invalid format return false
}
}
?> </code> </code>

والأن نحن نملك Function للتحقق من البريد الإلكترونى ، الآن سوف نحتاج إلى إنشاء Form بسيط مثل هذا

رمز PHP:

<code style="white-space:nowrap"> <code> <?php
function EmailForm(){
if(empty($_POST&#91;'email'&#93;)){
echo "<form action=".$_SERVER&#91;'PHP_SELF'&#93;." method='post'>
<table border='0'>
<tr>
<td>Email</td>
<td><input name='email' type='text' id='email' /></td>
</tr>
<tr>
<td> </td>
<td><input type='submit' name='Submit' value='Validate' /></td>
</tr>
</table>
</form>";
} elseif(isset($_POST&#91;'email'&#93;)) {
if(EmailValidation($_POST&#91;'email'&#93;)) {
echo "An email has been sent to you. Please follow the instructions to activate your account.";
} else {
echo "Your email address appears to be invalid. Please try again.";
}
} else {
echo "An error has occured, please contact the administrator.";
}
}
?> </code> </code>

والآن اضف هاذان الـ Functions وسوف يكون النظام جاهز للعمل ولللإختبار

رمز PHP:

<code style="white-space:nowrap"> <code> <?php
function EmailValidation($email) {
$email = htmlspecialchars(stripslashes(strip_tags($email))) ; //parse unnecessary characters to prevent exploits
if ( eregi ( '&#91;a-z||0-9&#93;http://www.dzbatna.com/images/mail.gif&#91;a-z||0-9&#93;.&#91;a-z&#93;', $email ) ) { //checks to make sure the email address is in a valid format
$domain = explode( "http://www.dzbatna.com/images/mail.gif", $email ); //get the domain name
if ( http://www.dzbatna.com/images/mail.giffsockopen ($domain&#91;1&#93;,80,$errno,$errstr,3)) {
//if the connection can be established, the email address is probabley valid
return true;
/*
GENERATE A VERIFICATION EMAIL
*/
} else {
return false; //if a connection cannot be established return false
}
} else {
return false; //if email address is an invalid format return false
}
}
function EmailForm(){
if(empty($_POST&#91;'email'&#93;)){
echo "<form action=".$_SERVER&#91;'PHP_SELF'&#93;." method='post'>
<table border='0'>
<tr>
<td>Email</td>
<td><input name='email' type='text' id='email' /></td>
</tr>
<tr>
<td> </td>
<td><input type='submit' name='Submit' value='Validate' /></td>
</tr>
</table>
</form>";
} elseif(isset($_POST&#91;'email'&#93;)) {
if(EmailValidation($_POST&#91;'email'&#93;)) {
echo "An email has been sent to you. Please follow the instructions to activate your account.";
} else {
echo "Your email address appears to be invalid. Please try again.";
}
} else {
echo "An error has occured, please contact the administrator.";
}
}
EmailForm();
?> </code> </code>

تم الإنتهاء وبحمد الله

إذا كان هناك أية إستفسارات ، انا متواجد للرد عليها
مع تحياتى / عمرو السيد

المصد : عمرو السيد - Amr El-Sayed: شرح طريقة عمل نظام Email Verification (http://amr-el-sayed.blogspot.com/2014/05/Email-Verification.html)








ألعاب الأندرويد مجانا و حصريا (http://www.apotox.info/forum)




https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-ak-ash4/482113_236967293114455_1193518507_n.png (http://www.dzbatna.com)
©المشاركات المنشورة تعبر عن وجهة نظر صاحبها فقط، ولا تُعبّر بأي شكل من الأشكال عن وجهة نظر إدارة المنتدى (http://www.dzbatna.com)©

استعمل مربع البحث في الاسفل لمزيد من المواضيع


سريع للبحث عن مواضيع في المنتدى