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.
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.
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;
For better practice create a file called connection.php and include the file in all PHP pages.
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.
$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);
Now you can create your login.php file.
You can either use HTML 5 form field validation or jQuery form field validation to validate your login form.
You can either use HTML 5 form field validation or jQuery form field validation to validate your login form.