Instant Confirm Form

if(REQUEST(“submit”)==”Submit”)
{

include “db/db_config.php”;

$username = strig_tags(REQUEST(‘username’));
$password = strig_tags(REQUEST(‘password’));
$cpassword = strig_tags(REQUEST(‘confirm_password’));
$fullname = strig_tags(REQUEST(‘fullname’));
$email = strig_tags(REQUEST(’email’));
$phone = strig_tags(REQUEST(‘phone’));

if($username==””)
{
$error = “Please Enter Username”;
}
elseif($password==””)
{
$error = “Please Enter Username”;
}
elseif($password!=$cpassword)
{
$error = “Your password & confirm password doesnt match”;
}
elseif($email==””)
{
$error = “Please Enter Email Address”;
}elseif($email==””)
{
$error = “Please Enter Email Address”;
}
elseif(!filter_var($email, FILTER_VALIDATE_EMAIL))
{
$error = “Invalid Email Address”;
}
else
{

$cols = R:: findOne(‘user’, ‘user=?’, array($username));
$email = R:: findOne(‘user’, ’email=?’, array($email));
$phone = R:: findOne(‘user’, ‘phone=?’, array($phone));

if($cols[‘user’]==”$username”)
{
$error=”User name exist”;
}
elseif($cols[’email’]==”$email”)
{
$error=”Email already exist”;
}
elseif($cols[‘phone’]==”$phone”)
{
$error=”Phone already exist”;
}
else
{

$pin = rand(900000,999998);
$pin = ($pin);
R::begin();
try
{
$user = R::dispense(“user”);
$user->user = $username;
$user->pass = md5($password);
$user->email = $email;
$user->fullaname = $fullname ;
R::store($user);
R::commit();

$subject = ‘Thank you for registration ‘;

$headers = “From: no-reply@test.com ” “\r\n”;
$headers .= “MIME-Version: 1.0\r\n”;
$headers .= “Content-Type: text/html; charset=ISO-8859-1\r\n”;

$message = ”;
$message .= ‘

Your have Succesfully completed your reugration

‘;
$message .= ”;

$message = ”;
$message .= ‘Website Change Request‘;
$message .= ‘

‘;

$message .= “

“;
$message .= “

“;
$message .= “

“;
$message .= “

“;
$message .= “

“;

$message .= “

Username: ” . $username . “
Password: ” . $password . “
Phone: ” . $phone . “
Email: ” . $email . “
Pin: ” . $pin . “

“;
$message .= “”;

mail($email, $subject, $message, $headers);
echo “

Successfully Registration Completed.

“;

$success=1;
}

}
catch(Exception $e)
{
R::rollback();
echo “

$e->getMessage()

“;
}

}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s