Thandava Krishna TK wrote:Hello,
One of my friends developed a small site using PHP code, and now he wants to add the login procedure to the site as well.We all know that we receive a confirmation email after getting registered on the site.He wants to add the same procedure to his site.Let me know the possible ways.
Thanks in advance
Developing user confirmation email can be done using "email" function provided in php language. Before proceeding I will consider that you have created table in database which contain username, password and hashkey [optional] for more security you can implement hash key too.
Using simple query you will be able to extract email id, password, hash key from database to form URL in email, which can be used for confirmation.
Code: Select all
$to = $email; // Email fetched from database
$subject = 'Signup | Verification'; // Specify subject for your email
//Below is message created to display user.
$message = '
Thanks for signing up!
Your account has been created, you can login with the following credentials after you have activated your account by pressing the url below.
Please click this link to activate your account:
$headers = 'From:firstname.lastname@example.org' . "\r\n"; // Remember to specify header.
mail($to, $subject, $message, $headers); // this is the function with appropriate parameter to send email to registered user.
In above code $name, $password, $email, $hash
are retrieve from database.
Hash key is optional which can be created while entering user detail in database and same can be store in one of the field of user_detail table to use it in future for verification.
Though you can pass email id in link and verify using that email id, you can also use hash key to make your url complex and difficult
to guess for naive user.