Here is the code. I have trouble with the registration process here. thanks anyway.
<?php
session_start();
include("connect.php");
$b_name = $_POST["txtbusinessname"];
$b_add = $_POST["txtbusinessadd"];
$email = $_POST["txtemailadd"];
$contact = $_POST["txtcontact"];
$cell = $_POST['txtcontact'];
$_SESSION["bname"]= $b_name;
$_SESSION["badd"]= $b_add;
$_SESSION["bemail"]= $email;
$_SESSION["bcontact"]= $contact;
$_SESSION["cell"] = $cell;
$format_cell = "+639";
if($b_name=="")
{
echo("<script>alert('Business Name is required')</script>");
echo" <script>window.location=\"../index.php\";</script> ";
return;
}
else if($b_add=="")
{
echo("<script>alert('Business Address is required')</script>");
echo" <script>window.location=\"../index.php\";</script> ";
return;
}
else if(!isValidEmail($email))
{
echo("<script>alert('Email address is invalid')</script>");
echo" <script>window.location=\"../index.php\";</script> ";
return;
}
else if($email=="")
{
echo("<script>alert('Email Address is required')</script>");
echo" <script>window.location=\"../index.php\";</script> ";
return;
}
else if($contact=="")
{
echo("<script>alert('Email Address is required')</script>");
echo" <script>window.location=\"../index.php\";</script> ";
return;
}
else if(strlen($cell) > 0)
{
$temp_cell = substr($cell,0,4);
if($temp_cell != $format_cell)
{
echo("<script>alert('Cellphone number format is incorrect')</script>");
echo" <script>window.location=\"../index.php\";</script> ";
return;
}
}
else {
$r = rand(10000, 1000000);
$result = mysql_query("insert into tbl_client_master(b_name,b_address,email,contactno) values('$b_name','$b_add','$email','$contact')") or die(mysql_error());
$result2 = mysql_query("insert into tbl_users(username,password,role) values('$email','$r','Client')");
$from = "********@gmail.com";
$body = "Thank you for registering with us <br><br> Your password is: $r";
$to = $email;
$subject = 'Frontline Production: Registration Complete';
$headers = "From: " . strip_tags('"********@gmail.com') . "\r\n";
$headers .= "Reply-To: ". strip_tags('"********@gmail.com') . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
require_once("PHPMailer/class.phpmailer.php");
define('GUSER', '**********@gmail.com'); // Gmail username
define('GPWD', '**********');
global $error;
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = GUSER;
$mail->Password = GPWD;
$mail->SetFrom($from, "Frontline Production");
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($to);
$mail->IsHTML(true);
if(!$mail->Send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
} else {
$error = 'Message sent!';
}
/*SMS*/
$_objSmsProtocolGsm = new Com("ActiveXperts.SmsProtocolGsm");
$objMessage = new Com ("ActiveXperts.SmsMessage");
$objConstants = new Com ("ActiveXperts.SmsConstants");
$objMessage->Recipient = $contact;
$objMessage->Format = $objConstants->asMESSAGEFORMAT_UNICODE;
$objMessage->Data = "Your password is: " . $r;
$_objSmsProtocolGsm->Device = "HUAWEI Mobile Connect - 3G Modem #2";
$_objSmsProtocolGsm->DeviceSpeed = 0;
if( $_objSmsProtocolGsm->LastError == 0 ){
$_objSmsProtocolGsm->Send( $objMessage );
}
$_SESSION["bname"]= "";
$_SESSION["badd"]= "";
$_SESSION["bemail"]= "";
$_SESSION["contact"]= "";
echo("<script>alert('Registration Successful, Please check your email for your password')</script>");
echo" <script>window.location=\"../index.php\";</script> ";
}
?>
<?php
function isValidEmail($email){
return filter_var($email, FILTER_VALIDATE_EMAIL);
}
?>