member not activating in user activation

Post here is you are having problems with any of the tutorials.
Post Reply
kevin1961
Posts: 4
Joined: Mon Dec 09, 2013 7:54 pm

member not activating in user activation

Post by kevin1961 »

hya i have followed this tutorial twice now and when u register the activation email comes through when i click it i get your account has been activate but when i try to login i get This account has not yet been activated.

and it generates a error in cpanel saying the following: [09-Dec-2013 13:20:15 America/Chicago] PHP Parse error: syntax error, unexpected T_STRING in /home/matureuk/public_html/core/inc/user.inc.php on line 62

if anyone can help would be much help

heres the coding for user.inc.php:

[syntax=php]
<?php

// checks if the given username exists in the database.
function user_exists($user){
$user = mysql_real_escape_string($user);

$total = mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `user_name` = '{$user}'");

return (mysql_result($total, 0) == '1')? true : false;
}

// checks if the given username and password combination is valid.
function valid_credentials($user, $pass){
$user = mysql_real_escape_string($user);
$pass = mysql_real_escape_string($pass);

$total = mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `user_name` = '{$user}' AND `user_password` = '{$pass}'");

return (mysql_result($total, 0) == '1') ? true : false;
}

//checks if the given user account is active.
function is_active($user){
$user = mysql_real_escape_string($user);

$sql = "SELECT
COUNT(`user_activation`,`user_id`)
FROM `users`
INNER JOIN `user_activations`
ON `users`,`user_id` = `user_activations`,`user_id`
WHERE `users`,`user_name` = '{$user}'";

$result = mysql_query($sql);

return (mysql_results($result, 0) == '0') ? true : false;
}
// activates the account related to the given activation code.
function activate_account($aid){
$aid = mysql_real_escape_string($aid);

mysql_query("DELETE FROM `user_activations` WHERE `activation_code` = '{$aid}'");
}

//adds a user to the database.
function add_user($user, $email, $pass){
$user = mysql_real_escape_string(htmlentities($user));
$email = mysql_real_escape_string($email);
$pass = sha1($pass);

$charset = array_flip(array_merge(range('a', 'z'), range('A', 'Z'), range('0', '9')));
$aid = implode('', array_rand($charset, 10));

$body ="

Hi,

Thanks for registering, before you login you need to activate your account.

To do that simply click the following link.

http://www.matureukswingers.co.uk/activate.php?aid={$aid}}

";

mail($email, 'Your new account at matureukswingers.co.uk', $body, 'From: matureukswingers.co.uk');

mysql_query("INSERT INTO `users` (`user_name`, `user_password`, `user_email`) VALUES ('{$user}', '{$pass}', '{$email}')");

$user_id = mysql_insert_id();

mysql_query("INSERT INTO `user_activations` (`user_id`, `activation_code`) VALUES ({$user_id},'{$aid}')");
}

?>[/syntax]
Last edited by Temor on Fri Dec 27, 2013 7:03 pm, edited 1 time in total.
Reason: Code tags!!!
ScTech
Posts: 92
Joined: Sat Aug 24, 2013 8:40 pm

Re: member not activating in user activation

Post by ScTech »

Line 62 looks like an empty line...It could be because of the extra } on line 61. You'll need to remove it anyways for the activation id to be valid. Also, please surround code in the syntax tags. They can be located as a button above the textbox when submitting a new post. In this case it would be the PHP button.

[syntax=php]<?php

// checks if the given username exists in the database.
function user_exists($user){
$user = mysql_real_escape_string($user);

$total = mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `user_name` = '{$user}'");

return (mysql_result($total, 0) == '1')? true : false;
}

// checks if the given username and password combination is valid.
function valid_credentials($user, $pass){
$user = mysql_real_escape_string($user);
$pass = mysql_real_escape_string($pass);

$total = mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `user_name` = '{$user}' AND `user_password` = '{$pass}'");

return (mysql_result($total, 0) == '1') ? true : false;
}

//checks if the given user account is active.
function is_active($user){
$user = mysql_real_escape_string($user);

$sql = "SELECT
COUNT(`user_activation`,`user_id`)
FROM `users`
INNER JOIN `user_activations`
ON `users`,`user_id` = `user_activations`,`user_id`
WHERE `users`,`user_name` = '{$user}'";

$result = mysql_query($sql);

return (mysql_results($result, 0) == '0') ? true : false;
}
// activates the account related to the given activation code.
function activate_account($aid){
$aid = mysql_real_escape_string($aid);

mysql_query("DELETE FROM `user_activations` WHERE `activation_code` = '{$aid}'");
}

//adds a user to the database.
function add_user($user, $email, $pass){
$user = mysql_real_escape_string(htmlentities($user));
$email = mysql_real_escape_string($email);
$pass = sha1($pass);

$charset = array_flip(array_merge(range('a', 'z'), range('A', 'Z'), range('0', '9')));
$aid = implode('', array_rand($charset, 10));

$body ="

Hi,

Thanks for registering, before you login you need to activate your account.

To do that simply click the following link.

http://www.matureukswingers.co.uk/activate.php?aid={$aid}}

";

mail($email, 'Your new account at matureukswingers.co.uk', $body, 'From: matureukswingers.co.uk');

mysql_query("INSERT INTO `users` (`user_name`, `user_password`, `user_email`) VALUES ('{$user}', '{$pass}', '{$email}')");

$user_id = mysql_insert_id();

mysql_query("INSERT INTO `user_activations` (`user_id`, `activation_code`) VALUES ({$user_id},'{$aid}')");
}

?>[/syntax]
<?php while(!$succeed = try()); ?>
kevin1961
Posts: 4
Joined: Mon Dec 09, 2013 7:54 pm

Re: member not activating in user activation

Post by kevin1961 »

ive done as instructed but i get a error msg in cpanel saying PHP Fatal error: Call to undefined function mysql_results() in /home/matureuk/public_html/core/inc/user.inc.php on line 35

heres the amended coding:
[syntax=php] <?php

// checks if the given username exists in the database.
function user_exists($user){
$user = mysql_real_escape_string($user);

$total = mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `user_name` = '{$user}'");

return (mysql_result($total, 0) == '1')? true : false;
}

// checks if the given username and password combination is valid.
function valid_credentials($user, $pass){
$user = mysql_real_escape_string($user);
$pass = mysql_real_escape_string($pass);

$total = mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `user_name` = '{$user}' AND `user_password` = '{$pass}'");

return (mysql_result($total, 0) == '1') ? true : false;
}

//checks if the given user account is active.
function is_active($user){
$user = mysql_real_escape_string($user);

$sql = "SELECT
COUNT(`user_activation`,`user_id`)
FROM `users`
INNER JOIN `user_activations`
ON `users`,`user_id` = `user_activations`,`user_id`
WHERE `users`,`user_name` = '{$user}'";

$result = mysql_query($sql);

return (mysql_results($result, 0) == '0') ? true : false;
}
// activates the account related to the given activation code.
function activate_account($aid){
$aid = mysql_real_escape_string($aid);

mysql_query("DELETE FROM `user_activations` WHERE `activation_code` = '{$aid}'");
}

//adds a user to the database.
function add_user($user, $email, $pass){
$user = mysql_real_escape_string(htmlentities($user));
$email = mysql_real_escape_string($email);
$pass = sha1($pass);

$charset = array_flip(array_merge(range('a', 'z'), range('A', 'Z'), range('0', '9')));
$aid = implode('', array_rand($charset, 10));

$body ="

Hi,

Thanks for registering, before you login you need to activate your account.

To do that simply click the following link.

http://www.matureukswingers.co.uk/activate.php?aid={$aid}}

";

mail($email, 'Your new account at matureukswingers.co.uk', $body, 'From: matureukswingers.co.uk');

mysql_query("INSERT INTO `users` (`user_name`, `user_password`, `user_email`) VALUES ('{$user}', '{$pass}', '{$email}')");

$user_id = mysql_insert_id();

mysql_query("INSERT INTO `user_activations` (`user_id`, `activation_code`) VALUES ({$user_id},'{$aid}')");
}

?>[/syntax]
kevin1961
Posts: 4
Joined: Mon Dec 09, 2013 7:54 pm

Re: member not activating in user activation

Post by kevin1961 »

also activate works but when i login i get a page page with no errors regarding this
ScTech
Posts: 92
Joined: Sat Aug 24, 2013 8:40 pm

Re: member not activating in user activation

Post by ScTech »

mysql_results() is not a predefined PHP function. Just remove the s so that it is mysql_result. Please use syntax tags....
<?php while(!$succeed = try()); ?>
kevin1961
Posts: 4
Joined: Mon Dec 09, 2013 7:54 pm

Re: member not activating in user activation

Post by kevin1961 »

i have the php tags already in after following betterphp tutorial on the email activation

but i dont have any idea where im being told to put the syntax tags can u help on this

thanks jan
ScTech
Posts: 92
Joined: Sat Aug 24, 2013 8:40 pm

Re: member not activating in user activation

Post by ScTech »

When posting code, use the [syntax=php]-Your code here-&lbrack;/syntax] tags with your code in between them. It makes it a lot easier to read and makes the page a lot easier to scroll down.

Are you still stuck on anything?
<?php while(!$succeed = try()); ?>
Post Reply