PDA

View Full Version : ثبت ایمیل



majoran
شنبه 25 اسفند 1386, 22:02 عصر
سلام من چطور می تونم بفهمم ایمیلی که کاربر برای ثبت نام در سایت وارد کرده به صورت واقعی هست یا نه .

function VF_form1(){ //v2.0
var theForm = document.form1;
var numRE = .@;
var errMsg = "";
var setfocus = "";

if (numRE.test(theForm['post_title14'].value == "")){
errMsg = "پست الکترونیکی اجباریست آن را وارد کنید";
setfocus = "['post_title12']";
}
if (theForm['post_title11'].value == ""){
errMsg = "نام کاربری یا مستعار خود را وارد نکرده اید";
setfocus = "['post_title11']";
}

if (theForm['post_title12'].value == ""){
errMsg = "کلمه عبور را وارد نکرده اید";
setfocus = "['post_title12']";
}

if (theForm['post_title12'].value != theForm['post_title13'].value){
errMsg = "کلمه عبور مورد نظر شما به درستی وارد نشده در ورود آن و کلمه عبور مجدد دقت نمایید";
setfocus = "['post_title12']";
}

if (theForm['post_title7'].value == ""){
errMsg = "سال ورود به دانشگاه را مشخص کنید";
setfocus = "['post_title7']";
}
if (theForm['post_title6'].value == ""){
errMsg = "نام پدر خود را وارد نکرده اید";
setfocus = "['post_title6']";
}
if (theForm['post_title5'].value == ""){
errMsg = "تاریخ تولد را وارد نکرده اید";
setfocus = "['post_title5']";
}
if (theForm['post_title4'].value == ""){
errMsg = "شماره شناسنامه خود را وارد کنید";
setfocus = "['post_title4']";
}
if (theForm['post_title3'].value == ""){
errMsg = "نام خانوادگی خود را وارد کنید";
setfocus = "['post_title3']";
}
if (theForm['post_title2'].value == ""){
errMsg = "نام خود را وارد نکرده اید";
setfocus = "['post_title2']";
}
if (theForm['post_title1'].value == ""){
errMsg = "شماره دانشجویی خود را وارد نکرده اید ";
setfocus = "['post_title1']";
}

if (errMsg != ""){
alert(errMsg);
eval("theForm" + setfocus + ".focus()");
}
else theForm.submit();
}//-->
</script>

Mah
یک شنبه 26 اسفند 1386, 07:15 صبح
سلام .
شاید با Yahoo API بتونی این کار رو انجام بدی .
یه جستجو تو یاهو انجام بده .
برای Gmail هم فکر می کنم ، امکانات مشابهی باشه .

راه بهتر همونی است که خودت انتخاب کردی . یک ایمیل برای کاربر می فرستی اگر ظرف مثلاً 72ساعت پاسخ داد نام کاربری را فعال می کنی ؛ در غیر این صورت حذفش کن .

majoran
یک شنبه 26 اسفند 1386, 10:50 صبح
مشکل من جای دیگست چطور می تونم بفهمم که کاربرم ایمیلی رو که فرستاده درست هست یعنی توش حروف @ و. وجود داشته باشه

raravaice
یک شنبه 26 اسفند 1386, 11:13 صبح
مشکل من جای دیگست چطور می تونم بفهمم که کاربرم ایمیلی رو که فرستاده درست هست یعنی توش حروف @ و. وجود داشته باشه

Regex

تو همین سایت مطلب دربارش زیاده.

موفق باشید

Bahram0110
یک شنبه 26 اسفند 1386, 11:32 صبح
if (instr($email, "@", false) == FALSE || instr($email, ".", false) == FALSE) {
Echo 'Invalid Email Address!';
}

Mah
یک شنبه 26 اسفند 1386, 12:23 عصر
سلام .
با استفاده از عبارات قاعده ای می توانی در سمت سرور یا کلاینت متن Email ورودی را چک کنی . اگر غلط بود آنگاه به کاربر پیام خطا بدی .

دوست من بهتر است ابتدا جستجو کنی . فکر می کنم این کدها مورد نیازت باشه .

سرور :



<?php
// email تابع تعیین اعتبار
function is_valid_email($string) {
return preg_match('/^[.\w-]+@([\w-]+\.)+[a-zA-Z]{2,6}$/', $string);
}

// روش استفاده از تابع
$email = "testing,bademail@sd";

if(is_valid_email($email) == true){
echo "$email is not a valid email";
} else {
echo "$email is a valid email";
}
?>


منبع : http://behravesh.ws/tutorial.php?id=41

کلاینت :




//**************************************
//HTML for :E-mail validator
//**************************************
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<title>e-mail validator</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
<!--

function emailvalid(frmno,elemno){
//Seth Lynch 22/10/01
//www.monomen.co.uk
//The textbox is referenced through the form number
//and the element number - both start at 0.
//I have tested it on ie5.5, ns4.72, ns6.1
//to call this function where there is only one form and the
//e-mail text box is the second item you would type
//onWhatever="return emailvalid('0','1');"
var frmno = frmno;//this is sent when calling the function
var elemno = elemno;//this is sent when calling the function
var doc = document.forms[frmno].elements[elemno];
//if email address is not compulsory delete the following statement
if(doc.value == ''){//they have not entered anything
alert("Please enter your e-mail address");
doc.focus();//focus is set to the e-mail box
return false;//stop processing
}

//if they enter an e-mail anndress ask them to confirm it if
//it fails reg-exp. if they say yes leave it as it is.
var regexpemail =/^[a-zA-Z0-9\-\.\_]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9 ]{1,3})(\]?)$/; //regexp for e-mail address
var str = doc.value; // value to compare
if (doc.value != '' && regexpemail.test(str) == false){//if email entry is not empty and regexp fails
var mailmsg = "";//build msg
mailmsg = ("Your e-mail address does not appear to be in a correct format.\n");
mailmsg += ("Can you confirm it is correct or make your correction below and click OK");
var email = "";
email = prompt(mailmsg,str);//mailmsg is the text the box will contain their entry for e-mail
doc.value = email;//what they type in will go into the e-mail box on the form
if (email == null){//if they cancel
doc.value = str;//they value will remain as they originaly typed it in
doc.focus();//focus is set to the e-mail box
return false;//no further processing
}
return false;//if you dont' want to trust them then change this to return false
//that way they have to enter a valid address
}
return true;//continue processing
}
-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="get" action="#">
<label for="email">E-mail address</label><br>
<input type="text" name="email" id="email"><br>
<input type="submit" name="Submit" value="Submit" onClick="return emailvalid('0 ','0')">
</form>
</body>
</html>
//**************************************
// Name: E-mail validator
// Description:Validate e-mail addresses
// By: Seth Lynch
//
//
// Inputs:a text field for the email address
//
// Returns:will produce an alert if no address is entered and a prompt if an incorrect address is entered
//
//Assumes:To call the function you need to send the from number and the element number, you count both of these from zero. So a single form where the email box is the third item would call it like this: onWhatever="return emailvalid('0','2');"
//
//Side Effects:None
//This code is copyrighted and has limited warranties.
//Please see http://www.Planet-Source-Code.com/xq/ASP/txtCodeId.2451/lngWId.2/qx/ vb/scripts/ShowCode.htm
//for details.
//**************************************
<script type="text/javascript">
<!--

function emailvalid(frmno,elemno){
//Seth Lynch 22/10/01
//www.monomen.co.uk
//The textbox is referenced through the form number
//and the element number - both start at 0.
//I have tested it on ie5.5,ie6, ns4.72, ns6.1
//to call this function where there is only one form and the
//e-mail text box is the second item you would type
//onWhatever="return emailvalid('0','1');"
var frmno = frmno;//this is sent when calling the function
var elemno = elemno;//this is sent when calling the function
var doc = document.forms[frmno].elements[elemno];
//if email address is not compulsory delete the following statement
if(doc.value == ''){//they have not entered anything
alert("Please enter your e-mail address");
doc.focus();//focus is set to the e-mail box
return false;//stop processing
}

//if they enter an e-mail anndress ask them to confirm it if
//it fails reg-exp. if they say yes leave it as it is.
var regexpemail =/^[a-zA-Z0-9\-\.\_]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9 ]{1,3})(\]?)$/; //regexp for e-mail address
var str = doc.value; // value to compare
if (doc.value != '' && regexpemail.test(str) == false){//if email entry is not empty and regexp fails
var mailmsg = "";//build msg
mailmsg = ("Your e-mail address does not appear to be in a correct format.\n");
mailmsg += ("Can you confirm it is correct or make your correction below and click OK");
var email = "";
email = prompt(mailmsg,str);//mailmsg is the text the box will contain their entry for e-mail
doc.value = email;//what they type in will go into the e-mail box on the form
if (email == null){//if they cancel
doc.value = str;//they value will remain as they originaly typed it in
doc.focus();//focus is set to the e-mail box
return false;//no further processing
}
return true;//if you dont' want to trust them then change this to return false
//that way they have to enter a valid address
}
return true;//continue processing
}
-->
</script>




منبع : http://www.iranw3.com/codes/js/form03.asp

موفق باشی .

امید امرایی
یک شنبه 26 اسفند 1386, 17:11 عصر
سلام من چطور می تونم بفهمم ایمیلی که کاربر برای ثبت نام در سایت وارد کرده به صورت واقعی هست یا نه .

واقعی بودن آدرس ایمیل می تونه 2 مفهوم متفاوت باشه .
1 : صحیح بودن ایمیل از نظر نحوی : که دوستان در مورد اون و استفاده از عبارات با قاعده توضیحات لازم رو دادند .
2 : واقعا وجود داشتن آدرس ایمیل : در این مورد می تونید از تابع زیر استفاده کنید .


checkdnsrr ()

توضیحات و مثال های یبشتر در آدرس :
http://ir.php.net/manual/en/function.checkdnsrr.php