Hello
Now verify the e-mail before saving in the database.
function returns zero if the mail is wrong or if one is true.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// check email
// check_em.prg
#include "FiveWin.ch"
func main()
local e_mail_ok="LIVESYSTEM_NET@HOTMAIL.COM"
local e_mail_error="LIVESYSTEM_NET#HOTMAIL.COM"
? C_CHECK_EMAIL(ALLTRIM(e_mail_ok))
? C_CHECK_EMAIL(ALLTRIM(e_mail_error))
return .t.
// ***********************************************
#pragma BEGINDUMP
#include "windows.h"
#include "hbapiitm.h"
#include "hbvm.h"
#include "hbstack.h"
#include "item.api"
#include "hbpcode.h"
#include "hbvmpub.h"
// --------- function check email --------------
#include <string.h>
int spc_email_isvalid(const char *address) {
int count = 0;
const char *c, *domain;
static char *rfc822_specials = "()<>@,;:\\\"[]";
/* first we validate the name portion (name@domain) */
for (c = address; *c; c++) {
if (*c == '\"' && (c == address || *(c - 1) == '.' || *(c - 1) ==
'\"')) {
while (*++c) {
if (*c == '\"') break;
if (*c == '\\' && (*++c == ' ')) continue;
if (*c <= ' ' || *c >= 127) return 0;
}
if (!*c++) return 0;
if (*c == '@') break;
if (*c != '.') return 0;
continue;
}
if (*c == '@') break;
if (*c <= ' ' || *c >= 127) return 0;
if (strchr(rfc822_specials, *c)) return 0;
}
if (c == address || *(c - 1) == '.') return 0;
/* next we validate the domain portion (name@domain) */
if (!*(domain = ++c)) return 0;
do {
if (*c == '.') {
if (c == domain || *(c - 1) == '.') return 0;
count++;
}
if (*c <= ' ' || *c >= 127) return 0;
if (strchr(rfc822_specials, *c)) return 0;
} while (*++c);
return (count >= 1);
}
// ------------------------
//------------- function check email -----------
HB_FUNC ( C_CHECK_EMAIL )
{
int RET_N=0;
char far *URL_EMAIL;
URL_EMAIL = hb_parc(1);
RET_N=spc_email_isvalid((const char *)URL_EMAIL);
hb_retni(RET_N);
}
// *************************
#pragma ENDDUMP
++++++++++++++++++++++++
greetings to you all.
Hathal.