// START OF INFO //**************************** // You may use this script as you wish // Please don't remove this lines // // Validate Email with PHP and enter data on DB // author: Rúben Gomes // email: rubengomes@yzonk.com // website: www.rubengomes.yzonk.com // 06/04/2006 //**************************** // This script uses the "$_SERVER['SCRIPT_NAME']" variable, // therefore all the code is presented in this page and // no other file is nedded. //END OF INFO //START OF DATA YOU CAN CHANGE // Client REF // $cli_login = "bcn"; // Satus Messages $error_message = "Corrija os dados assinalados."; // This is the Sucess message passed to the user, // aknowloging him that his registration was sucesseful. $success_message = "O seu Registo foi efectuado com sucesso."; //END OF DATA YOU CAN CHANGE ?> $query = "SELECT * FROM `tb_notice` WHERE `not_client` = '$cli_login'"; $raw_data = mysql_query($query); $num_rows = 0; if($raw_data != ''){ $num_rows = mysql_num_rows($raw_data); } mysql_close(); ?> // START OF Registration Function function Registration($cli_login,$txt_name,$txt_email){ include("mysql_connect_notice.inc.php"); $query = "INSERT INTO `tb_notice` VALUES ('','$cli_login','$txt_name','$txt_email')"; mysql_query($query); mysql_close(); } // END OF Registration Function // START OF Validate Email Function function ValidateEmail($txt_email){ // $valid_email = 0 --> invalid // $valid_email = 1 --> valid // Start as if it was an invalid email $valid_email = 0; // Validate the Syntax if (eregi("^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $txt_email)){ list($username,$domain_tld) = split("@",$txt_email); // Validate the Domain if (getmxrr($domain_tld,$mxrecords)){$valid_email = 1;} } return $valid_email; } // END OF Validate Email Function // START OF Receive Data // $action = --> Write Message // $action = 1 --> Validate Data // $action = 2 --> Send Email // $action = 3 --> Email Sent $action = $_POST['action']; $txt_email = $_POST['txt_email']; $txt_name = $_POST['txt_name']; // END OF Receive Data // START OF Validating the Data if ($action == 1){ // If all the camps are filled if ($txt_email != '' && $txt_name != ''){ // Validate the email if (ValidateEmail($txt_email)){$action = 2;} } } // END OF Validating the Data // START OF Registration if ($action == 2){ // Calling Function Registration Registration($cli_login,$txt_name,$txt_email); $action = 3; // Registration was made // START OF Clear Variables $txt_action = 1; $txt_email = ""; $txt_name = ""; // END OF Clear Variables } // END OF Sending the Registration ?>
|
||||||||||||