This topic is locked

Activate Existing users

8/18/2010 10:45:20 PM
PHPRunner General questions
I
indigo author

Hi,
I already have a phprunner app running with lots of users.

Now, we want to implement "email activation" for both new and existing users.

For new users, it is fairly easy.
How can I verify existing users?

I have read the script and understand that verification is based on MD5 of username and password fields.

But I need to redirect users to a page so that they get a link in their mailbox & can verify email address before using the application.
Please help.

A
ann 8/19/2010

Hi,
you can add the code to the Before Login event in order to check if the useк account is verified.

Here is just a sample:



$rs=CustomQuery("select verification from users where username=".$username);

$data=db_fetch_array($rs);

if (!$data["verification"]){

$url = GetSiteUrl();

$url.=$_SERVER["SCRIPT_NAME"];

// send email to user

$message="You have registered as a user at"." ".$url."\r\n\r\n";

$message.= "Click this link to confirm your account and finish the registration".":\r\n";

$message.= $url."?a=activate&u=".rawurlencode(base64_encode($username))."&code=";

$message.=rawurlencode(md5($username.md5($password)));

$message.="\r\n("."If you are unable to click on the link, copy and paste it into your browser window.".")\r\n\r\n";

$strLabel = "Username";

$message.=$strLabel.": ".$username."\r\n";

$strLabel = "Password";

$message.=$strLabel.": ".$password."\r\n";

$strLabel = "Email";

$message.=$strLabel.": ".$values["email"]."\r\n";

if(($pos=strpos($strEmail,"\r"))!==FALSE || ($pos=strpos($strEmail,"\n"))!==FALSE)

$strEmail=substr($strEmail,0,$pos);

runner_mail(array('to' => $strEmail, 'subject' => "Notification on registering", 'body' => $message));

}



where verification, username are field names of the users table.

You can also check how it's done on the register page in the generated resister.php file.

I
indigo author 8/20/2010

Hi,
I guess this works alright.

But when a user tries to login without verification, the message says "Invalid Login".

"Invalid Login" does not clearly says that they need Verify their email address.
Can we have the following:

  1. A message which says that the user need to verify his email ID.
  2. A link where a user can click and an email for verification is sent.
    thx

I
indigo author 8/20/2010

Hi,
I got this solved.

Added a php code to "AfterUnsuccessfulLogin" function and it works.

Thanks for your help.