getMessage(); } if(!$client) { header('Location: standby.php'); die(); } //Library for Captch to control Registration Forms //include("captcha/simple-php-captcha.php"); if (($_SERVER['REQUEST_METHOD'] == "POST") && (isset(XXXXXX['register']))) { XXXXXXXXX['Status'] = '';// Hold the status of submitted form //initialize variables from POST form $firstName = strtoupper(filter_input(INPUT_POST,'firstName', FILTER_SANITIZE_STRING)) ; $lastName = strtoupper(filter_input(INPUT_POST,'lastName', FILTER_SANITIZE_STRING)); $useremail = strtolower(filter_input(INPUT_POST,'useremail', FILTER_SANITIZE_EMAIL)); $country = strtoupper(filter_input(INPUT_POST,'country', FILTER_SANITIZE_STRING)); $mobile = filter_input(INPUT_POST,'mobile', FILTER_SANITIZE_STRING); $password = filter_input(INPUT_POST,'password'); $confpassword = filter_input(INPUT_POST,'confpassword'); //$captcha = filter_input(INPUT_POST,'captcha'); //$regno = filter_input(INPUT_POST,'regno', FILTER_SANITIZE_STRING); $regtoken = filter_input(INPUT_POST,'regtoken'); //Sessions for Registration Form XXXXXXXXX['firstName'] = (isset($firstName)) ? $firstName : ''; XXXXXXXXX['lastName'] = (isset($lastName)) ? $lastName : ''; XXXXXXXXX['useremail'] = (isset($useremail)) ? $useremail : ''; XXXXXXXXX['country'] = (isset($country)) ? $country : ''; XXXXXXXXX['mobile'] = (isset($mobile)) ? $mobile : ''; //XXXXXXXXX['regno'] = (isset($regno)) ? $regno : ''; //Validate the Posted Data //validate FORM token to check if Form is being submitted from required Page by Non Malicious User / No Refresh if(strlen($regtoken) == 0 ) { die('Something Went Terribly Wrong... Please Try Again!'); } //check if session and Submitted Token Match if($regtoken !== XXXXXXXXX['regformtoken'] ) { die('Something Went Terribly Wrong... Please Try Again!'); } //validate First Name if(strlen($firstName) == 0 ) { XXXXXXXXX['Status'] = 'failed'; XXXXXXXXX['firstNameError'] = 'Please fill in your First Name !'; } //check if Digits exist in firstname $regexcheckdigits = '/\d/'; if (preg_match($regexcheckdigits, $firstName)) { XXXXXXXXX['Status'] = 'failed'; XXXXXXXXX['firstNameError'] = 'Name can not include digits !'; } //validate Last Name if(strlen($lastName) == 0 ) { XXXXXXXXX['Status'] = 'failed'; XXXXXXXXX['lastNameError'] = 'Please fill in your Last Name !'; } //check if Digits exist in lastname $regexcheckdigits = '/\d/'; if (preg_match($regexcheckdigits, $lastName)) { XXXXXXXXX['Status'] = 'failed'; XXXXXXXXX['lastNameError'] = 'Name can not include digits !'; } //validate Useremail if(strlen($useremail) == 0 ) { XXXXXXXXX['Status'] = 'failed'; XXXXXXXXX['useremailError'] = 'Please fill in your email !'; } //validate email if (!filter_var($useremail, FILTER_VALIDATE_EMAIL)) { XXXXXXXXX['Status'] = 'failed'; XXXXXXXXX['useremailError'] = 'Please enter a Valid Email !'; } //validate Country if(strlen($country) == 0 ) { XXXXXXXXX['Status'] = 'failed'; XXXXXXXXX['countryError'] = 'Please fill in your Country !';//Die } //validate Mobile if(strlen($mobile) == 0 ) { XXXXXXXXX['Status'] = 'failed'; XXXXXXXXX['mobileError'] = 'Please fill in your Mobile Number !'; } //check if mobile is at more than 7 digits if (strlen($mobile) < 8) { XXXXXXXXX['Status'] = 'failed'; XXXXXXXXX['mobileError'] = 'Mobile Number should be at leat 8 digits!'; } //check kenya mobile Number if($country == 'KENYA') { $regex= "/^\+254\d{9}$/"; $kenyanumber = preg_match($regex, $mobile); if (!$kenyanumber) { XXXXXXXXX['Status'] = 'failed'; XXXXXXXXX['mobileError'] = 'Wrong Mobile Number for Kenya. Try Format [+2547XXXXXXXX]'; } } //validate Password if(strlen($password) == 0 ) { XXXXXXXXX['Status'] = 'failed'; XXXXXXXXX['passwordError'] = 'Please fill in your Password!'; } //password strength if (preg_match("/^.*(?=.{6,})(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).*$/", $password ) === 0) { XXXXXXXXX['Status'] = 'failed'; XXXXXXXXX['passwordError'] = '* Minimum 6 characters, 1 UPPERCASE, 1 lowercase & at least 1 Digit !'; } //validate Conform Password if(strlen($confpassword) == 0 ) { XXXXXXXXX['Status'] = 'failed'; XXXXXXXXX['confpasswordError'] = 'Please Confirm your Password !'; } $passmatch = ($confpassword == $password) ? 'yes':'no'; if ($passmatch == 'no') { XXXXXXXXX['Status'] = 'failed'; XXXXXXXXX['confpasswordError'] = 'Passwords DO NOT Match ..!'; } if(XXXXXXXXX['Status'] == 'failed') { header("Location: register.php"); die(); } else { //clear all sessions to remember for details XXXXXXXXX['firstName'] = ''; XXXXXXXXX['lastName'] = ''; XXXXXXXXX['useremail'] = ''; XXXXXXXXX['country'] = ''; XXXXXXXXX['mobile'] = ''; //XXXXXXXXX['regno'] = ''; //Validation token for Login $random = mt_rand(0, 99999); $salt = "asj#$^2Cb8"; $combi = $random.$salt; $token = hash('sha256',$combi); //user validate token $salt2 = "df%&BS&*16"; $t = time(); $con = mt_rand(0,99999).$t.$salt2; $userkey = hash('sha256',$con); //initialize variables for WSDL Call declared at Start $arg0 = $useremail; $arg1 = $password; $arg2 = $confpassword; $arg3 = $firstName.' '.$lastName; $arg4 = $mobile; $arg5 = 1; $arg6 = $userkey; $arg7 = $country; // $arg8 = isset($regno) ? $regno : ''; $parameters= array("arg0"=>$arg0,"arg1"=>$arg1,"arg2"=>$arg2,"arg3"=>$arg3,"arg4"=>$arg4,"arg5"=>$arg5, "arg6"=>$arg6, "arg7"=>$arg7); $values = $client->createUser($parameters); $usercreated = isset($values->return) ? $values->return : null ; //Returned Variables if($usercreated != null) { //clientcode $clientCode = $usercreated->clientCode; //message $tunrkcreatemsg = $usercreated->message; } else { header('Location: register.php?er=4'); die(); } switch ($tunrkcreatemsg) { case ' Login Successfull': //send validation email //Create a new PHPMailer instance $mail = new PHPMailer; //Tell PHPMailer to use SMTP $mail->isSMTP(); //Enable SMTP debugging // 0 = off (for production use) // 1 = client messages // 2 = client and server messages $mail->SMTPDebug = 0; //Ask for HTML-friendly debug output //$mail->Debugoutput = 'html'; //Set the hostname of the mail server $mail->Host = $mailhost; //Set the SMTP port number - likely to be 25, 465 or 587 $mail->Port = $mailport; //Whether to use SMTP authentication $mail->SMTPAuth = true; //Username to use for SMTP authentication $mail->Username = $mailusername; //Password to use for SMTP authentication $mail->Password = $mailpassword; //Set who the message is to be sent from $mail->setFrom($mailFromEmail, $mailFromName); //Set an alternative reply-to address $mail->addReplyTo($replytoemail, $replytoname); //Set who the message is to be sent to $mail->addAddress($useremail, $arg3); //Set the subject line $mail->Subject = 'Account Activation'; //Read an HTML message body from an external file, convert referenced images to embedded, //convert HTML into a basic plain-text alternative body $mail->Body = ""; $mail->Body.= '
'; $mail->Body.= '
The Heritage Insurance Company Client Portal
'; $mail->Body.= '
'; $mail->Body.= '

Dear '.$arg3.'

'; $mail->Body.= '

Thank you for Registering your account on our Client Portal.

'; $mail->Body.= '

Please : Click here to Activate your Account Now

'; $mail->Body.= '

Note that your email address will be your Username for Login.

'; $mail->Body.= '

Regards

The Heritage Insurance Company kenya Ltd.
P: (020) 278 3000 / 0711 039 000 / 0734 101 000
Tel: +254 20 2783000 / 2726439 / 2726440
Mobile: 0711 039 000/ 0734 101 000

'; $mail->Body.= '
'; $mail->Body.= '
Terms and Conditions Apply.
'; $mail->Body.= '
'; //mail as HTML $mail->IsHTML(true); //send Mail $mail->send(); @header('Location: index.php?er=3'); die(); break; case ' Account Already Exists For Client. Have you forgotten your Password? ': header('Location: index.php?er=5'); die(); break; default: echo ""; } } }//if for if Button Register was presssed $view_path = 'register-view.php'; include 'views/layout.php'; ?>