How to register in php(Sign up form in php)
Basically
in register form is register by email, mobile number, username etc. The purpose
of register(sign up) to add the user in system who get the benefits of
system(Application).The logic of register(sign up) is no duplicate users
allowed in application with form validation.Password and Confirm password input
must be same.below are steps to develop sign up (register) in the Application.
Steps:
1. Create Database
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL,
`first_name` varchar(200) NOT NULL,
`last_name` varchar(200) NOT NULL,
`email` varchar(100) NOT NULL,
`password` varchar(100) NOT NULL,
`status` varchar(50) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL
) ENGINE=InnoDB
AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `first_name`, `last_name`, `email`, `password`, `status`, `created_at`, `updated_at`) VALUES
(1, 'ABC', 'XYZ', 'abc@fff.com', '789456', 'active', '2018-03-01 00:00:00', '2018-03-01 00:00:00');
2. Register.php
<?php
require_once 'config.php';//This file include for database configuration.
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
require_once 'config.php';//This file include for database configuration.
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$password = $_POST['password'];
$confirm_password = $_POST['confirm_password'];
if(empty($first_name) || empty($last_name) || empty($email) || empty($password) || empty($confirm_password))
if(empty($first_name) || empty($last_name) || empty($email) || empty($password) || empty($confirm_password))
{
$error = " * Please fill all
field";
}
else
{
if($password != $confirm_password)
{
$error = "Password and Confirm
Password not matched";
}
else{
$passwordSecure=md5($password);
$sql="INSERT INTO
`basicphp`.`users` (`first_name`, `last_name`, `email`, `password`, `status`)
VALUES ('$first_name', 'last_name', '$email', '$passwordSecure', 'active');";
if(mysqli_query($db,$sql)){
$error = "You are successfully
registered";
}
}
}
}
?>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"><link href="style.css" rel="stylesheet">
<script
src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script
src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the
above in your HEAD tag ---------->
<div class = "container">
<div class="wrapper">
<form action="" method="post"
name="Login_Form" class="form-signin">
<span style="color:red"><?php echo isset($error) ? $error :
''; ?></span>
<h3 class="form-signin-heading">Please Register</h3>
<hr class="colorgraph"><br>
<input type="text" class="form-control"
name="first_name" placeholder="First name"
autofocus="" />
<br/>
<input type="text" class="form-control"
name="last_name" placeholder="Last name"
/>
<br/>
<input type="text" class="form-control"
name="email" placeholder="Email"
/>
<br/>
<input type="password" class="form-control"
name="password" placeholder="Password"
/>
<input type="password" class="form-control"
name="confirm_password" placeholder="Confirm
password" />
<br/>
<button class="btn btn-lg btn-primary btn-block" name="register"
value="Register" type="Submit">Register</button>
</form>
</div>
</div>
Comments
Post a Comment