Lets assume you want to create a simple registration form with like first name, last name, email and password. Here visitor will fill-up the simple registration form then verify their email address and eligible to login. 

HTML Code to Create Registration Form:

You can either use HTML 5 form field validation or jQuery form field validation . Also use captcha to prevent spam. You can use custom captcha or re-captcha provided by Google.

Create MySQL Table:

Lets create our mysql table to store data from registration form.

CREATE TABLE `register` (
  `userid` int(11) NOT NULL auto_increment,
  `fname` varchar(50) NOT NULL,
  `lname` varchar(50) NOT NULL,
  `email` varchar(50) NOT NULL,
  `password` varchar(100) NOT NULL,
  `status` varchar(10) NOT NULL,
  PRIMARY KEY  (`userid`),
  UNIQUE KEY `userid` (`userid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
Create DataBase Connection Through PHP:

For better practice create a file called connection.php and include the file in all PHP pages. 

Save Data Into MySQL Table :

Here we have used MD5 encoding to protect password. You can use any other password encoding options available in PHP.

If you doesn't want user's email verification then you can make $status='active' and send the user to my account page.

Send Activation Mail to User:
$to = $email;
$from = "info@a2zwebhelp.com";
$subject = "Activate your Account";
$message = "
Click here to activate your account.";

$headers = "MIME-Version: 1.0\r\nContent-type: text/html; charset=utf-8\r\n";
$headers .= "From: \"" . $from . "\" \r\n";
$headers .= "Reply-To: " . $to . "\r\n";
$message = utf8_decode($message);

mail($to, $subject, $message, $headers);
Create your activete.php file:

Now you can create your login.php file.

Create Your Login Form:

You can either use HTML 5 form field validation or jQuery form field validation to validate your login form.

Validate user authentication through PHP:
Create Your Login Form :

You can either use HTML 5 form field validation or jQuery form field validation to validate your login form.

Validate user authentication through PHP: