* or visit my blog on http://www.phptricks.org * * */ if (isset($_POST['addNewUser'])) { $post_ = escape($_POST); $errors = array(); if (!preg_match("/^[a-zA-Z_\\-.0-9]/", $post_['UserName'])) { $errors[] = "the username must be Latin characters , Numbers and ( . , - , _ ) charcters ONLY "; } if (!filter_var($post_['UserEmail'], FILTER_VALIDATE_EMAIL)) { $errors[] = "invalid email address"; } if (!count($errors)) { $send = new Sender(); if ($send->sendThanksTemplateAndActivationKey($post_['UserName'], $post_['UserEmail'])) { echo "Added Successfuly ... See your Email ...."; } else { echo implode('<br>', $send->getErrors()); } } else { echo implode('<br>', $errors); } } ?> <form method="POST"> User Name: <input name="UserName" type="text"> <br><br> User Email: <input name="UserEmail" type="text"> <br>
* DEMO FILE .. */ require_once 'load.php'; $data = array('u_name' => 'test', 'u_email' => 'test', 'activation_key' => 'test'); if (isset($_POST['add_user'])) { $errors = array(); $post_ = escape($_POST); if (!preg_match("/^[a-zA-Z_\\-.0-9]/", $post_['user_name'])) { $errors[] = "the username must be Latin characters , Numbers and ( . , - , _ ) charcters ONLY "; } if (!filter_var($post_['user_email'], FILTER_VALIDATE_EMAIL)) { $errors[] = "invalid email address"; } if (!count($errors)) { $send = new Sender(); if ($send->sendThanksTemplateAndActivationKey($post_['user_name'], $post_['user_email'])) { echo "Added Successfuly ... See your Email ...."; } else { echo implode('<br>', $send->getErrors()); } } else { echo implode('<br>', $errors); } } ?> <form action="?subscribe=on" method="POST"> <input type="text" name="user_name"> <br> <input type="text" name="user_email"> <br>