/    Sign up×
Community /Pin to ProfileBookmark

Activation notification help

In order for my users to log in they have to activate their account through email. The activation works fine, and the users can log in, if they have activated. The trouble I am having is displaying a message at login if the user has not activated, so they know why they cannot log in. Here is the activation script:

[code]
<?php
require “connect.php”;

if(isset($_GET[‘u’])){
//make sure that ‘u’ is numeric
if(is_numeric($_GET[‘u’])){
$u=$_GET[‘u’];
}else{
$u=0;
}
}

if(isset($_GET[‘a_code’])){
$code=$_GET[‘a_code’];
}else{
$code=0;
}

//Check to see if the received values are correct
$sql = “SELECT * FROM members WHERE uid = ‘”.$u.”‘ AND actcode = ‘”.md5(0).”‘”;
if(($u > 0) && (strlen($code)) == 32){

//now activate the user
$sql=”UPDATE members SET actcode ='”.md5(1).”‘ WHERE uid = ‘”.$u.”‘”;

$res = mysql_query($sql) or die(mysql_error());

if(mysql_affected_rows() == 1){

//update successful
echo (‘Your account is now activated. You may proceed and log in.<br/><br /><a href=”http://www.eternalhour.com/login.php”>Login Page</a>’);
}else{
echo (‘Your account could not be activated. Please try again or contact the site admin.<br/><br/><a href=”http://www.eternalhour.com/registration_form.php”>Registration Page</a>’);
}
}
?>
[/code]

I imagine I need to add something similar to the following to my login script, to find out if the user has activated:

[code]
if(isset($_GET[‘u’])){
$u=$_GET[‘u’];
}

$sql = “SELECT * FROM members WHERE uid = ‘”.$u.”‘ AND actcode = ‘”.md5.”‘”;
if($row[‘actcode’]) == (md5(1)){

}else{
$msg = “You need to activate your account before logging in.”;
}
[/code]

However, I cannot get it working. Could someone please help me with this?

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@UAL225Aug 28.2009 — [code=php]if(isset($_GET['u'])){
$u=$_GET['u'];
}

$sql = "SELECT * FROM members WHERE uid = '".$u."' AND actcode = '".md5."'";
if($row['actcode']) == (md5(1)){

}else{
$msg = "You need to activate your account before logging in.";
}[/code]


make the [code=php]$msg[/code] into an [code=php]echo"";[/code] and that will echo on the screen that they have not activated the account or you can make it echo the msg, what ever is better for you.
×

Success!

Help @Tekkno spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...