Jump to content

Email Authentication ?


Accurax

Recommended Posts

Happy new year Chaps & Chapettes,

I have a membership system allready in place, and would like to make it so that the user must activate there acount by clicking on a link within a generated email that is sent after the registration process.

I cant seem to find all that much that is specifically relevant to this via google, and thought id as if anyone here could point me to a resource that may explain whats involved in acheiving this.

Thanks in advance
Link to comment
https://forums.phpfreaks.com/topic/32686-email-authentication/
Share on other sites

in your database, put a field for "active" varchar(1) default(0), and another "activekey" varchar(40)
then when you sign up, you put in info into database

[code]
<?
$key=randomkeys(40);
mysql_query("INSERT INTO users(`activekey`) VALUES('$key')");
mail();#have $key link sent to the user

function randomkeys($length){
$pattern = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
for($i=0;$i<$length;$i++) $key .= $pattern{rand(0,62)};
return $key;
}
?>[/code]

then on your activate page

[code]
mysql_query("UPDATE users SET active='1' WHERE key='$key'");
[/code]
Link to comment
https://forums.phpfreaks.com/topic/32686-email-authentication/#findComment-152116
Share on other sites

its easier to just put it into the login form ;-)

[code]
$password=md5($_POST['password']);
$result = mysql_query("SELECT * FROM users WHERE `username`='$_POST['username']' AND `password`='$password' LIMIT 1");
$row=mysql_fetch_array($result);
if($active==0) die("Account Not Yet Active");
[/code]
Link to comment
https://forums.phpfreaks.com/topic/32686-email-authentication/#findComment-152121
Share on other sites

yes, md5 gives you 32 character cypher, if you want more/less/more secure, use this...
[code]
function randomkeys($length){
$pattern = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
for($i=0;$i<$length;$i++) $key .= $pattern{rand(0,62)};
return $key;
}
$key=randomkeys(rand(32,40));
echo $key; #display purposes
[/code]
Link to comment
https://forums.phpfreaks.com/topic/32686-email-authentication/#findComment-152127
Share on other sites

Most sites I see just use the MD5 hash of the password.

[code]
<?php
if(isset($_GET['key'])) {
  $key = $_GET['key'];

  // check key against md5 hash that is store in the database (or whereever)
  if($key == $users['password']) {
    // Activate the account
  } else {
    // Keys don't match, go mental!
  }
}
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/32686-email-authentication/#findComment-152304
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.