In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to use Php to write Email activation verification after registration. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
A total of two pages are required, register.php and verify.php
1. User registration form register.php
The copy code is as follows:
User name:
Password:
Email:
two。 Create a user data table Users
The copy code is as follows:
CREATE TABLE IF NOT EXISTS `users` (
`id`int (11) NOT NULL auto_increment
`status` varchar (20) NOT NULL
`username` varchar (20) NOT NULL
`password` varchar (20) NOT NULL
`email` varchar (20) NOT NULL
`activationkey` varchar (100) NOT NULL
PRIMARY KEY (`id`)
UNIQUE KEY `username` (`username`)
UNIQUE KEY `email` (`email`)
UNIQUE KEY `activationkey` (`activationkey`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=9
3. Create CAPTCHA and store the user registration information in the data table
We use the status' verify' to represent users who have not been activated.
The copy code is as follows:
$activationKey = mt_rand (). Mt_rand (). Mt_rand (). Mt_rand (). Mt_rand ()
$username = mysql_real_escape_string ($_ post [username])
$password = mysql_real_escape_string ($_ post [password])
$email = mysql_real_escape_string ($_ post [email])
$sql= "INSERT INTO users (username, password, email, activationkey, status) VALUES ('$username','$password','$email','$activationKey', 'verify')"
4. Send verification code
The copy code is as follows:
Echo "An email has been sent to $_ post [email] with an activation key. Please check your mail to complete registration."
# # Send activation Email
$to = $_ post [email]
$subject = "YOURWEBSITE.com Registration"
$message = "Welcome to our website!\ r\ rYou, or someone using your email address, has completed registration at YOURWEBSITE.com. You can complete registration by clicking the following link:\ r http://www.YOURWEBSITE.com/verify.php?$activationKey\r\rIf this is an error, ignore this email and you will be removed from our mailing list.\ r\ rRegards,\ YOURWEBSITE.com Team"
$headers = 'From: noreply@ YOURWEBSITE.com'. "\ r\ n".
'Reply-To: noreply@ YOURWEBSITE.com'. "\ r\ n".
'X-Mailer: PHP/'. Phpversion ()
Mail ($to, $subject, $message, $headers)
5. Verify the activation code verify.php
If the verification code is the same, the user is activated.
The copy code is as follows:
$queryString = $_ SERVER ['QUERY_STRING']
$query = "SELECT * FROM users"
$result = mysql_query ($query) or die (mysql_error ())
While ($row = mysql_fetch_array ($result)) {
If ($queryString = = $row ["activationkey"]) {
Echo "Congratulations!". $row ["username"]. "is now the proud new owner of a YOURWEBSITE.com account."
$sql= "UPDATE users SET activationkey ='', status='activated' WHERE (id = $row [id])"
If (! mysql_query ($sql)) {
Die ('Error:'. Mysql_error ()
}
/ / at this point, the user has fully activated the account, and you can jump to the interface after login.
}
} / / end of while
On "how to use Php to write Email activation verification after registration" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.