Jump to content
MakeWebGames

Recommended Posts

Posted (edited)

Help! i have a prob with my email Validation, it sends email to user the link works fine, updates the users table form 0 to 1 but still cant login

 

authenticate.php

$uq=$db->query("SELECT userid FROM users WHERE login_name='{$_POST['username']}' AND `userpass`=md5('{$_POST['password']}')");
if ($db->num_rows($uq)==0)
{
die("<h3>{$set['game_name']} Error</h3>
$invalid<br>
<a href=login.php>> $lerrortry</a>");
}

if($ir['confirmed'] == 0)

{
die("Your account is not active, check your email address including junk boxes.
<a href=login.php>> Back</a>");
}
else

 

activation.php

$code=$_GET['code'];
$cq=mysql_query("select * from confirm where code=$code",$c);
if(mysql_num_rows($cq)== 0)
{ die("Invalid Validation Code"); }
$r=mysql_fetch_array($cq);
if($_GET['act'] == 'activate')
{
mysql_query("UPDATE users SET confirmed='1' WHERE userid={$r[user]}",$c);
mysql_query("DELETE FROM confirm WHERE code=$code",$c);
print "Account Validated!<br />
<a href='login.php'>Login</a>";
} else if($_GET[act] == 'cancel')

 

signup.php

if($_POST['ref']) {
$q=$db->query("SELECT * FROM users WHERE userid={$_POST['ref']}");
$r=$db->fetch_row($q);
}


$db->query("INSERT INTO users (username, display_pic, login_name, userpass, level, money, crystals, donatordays, user_level, energy, maxenergy, will, maxwill, brave, maxbrave, hp, maxhp, location, gender, signedup, email, bankmoney, lastip,  confirmed) VALUES( '{$username}', 'http://{$_SERVER['HTTP_HOST']}/images/avatar.gif', '{$username}', md5('{$_POST['password']}'), 1, $sm, 0, 0, 1, 12, 12, 100, 100, 5, 5, 100, 100, 1, '{$_POST['gender']}', unix_timestamp(), '{$_POST['email']}', -1, '$ip', 0)",$c); 
Edited by boots
Posted

If the the activation link is successfully sent, and the table is set from false to true, there is obviously not a problem in the activation.php and signup.php code, so you wouldn't need to provide that code. Secondly, I am not familiar to MCCode other than it looks really bad, where do you get access to $ir? What errors/display do you get when trying to log in?

Posted (edited)

No errors just cant login, cant understand it all looks ok, also tried

if ($mem['confirmed'] == 0)

but same prob, Your account is not active, check your email address

Edited by boots
Posted

this would be my way, Delete the db info you put into users,

get the db sql and set default to 1.

send that. then go to users in the database and change the default back to 0, making all current users be sorted and new users will get default 0.

There is definably an easier way but that's mine.

Posted
this would be my way, Delete the db info you put into users,

get the db sql and set default to 1.

send that. then go to users in the database and change the default back to 0, making all current users be sorted and new users will get default 0.

There is definably an easier way but that's mine.

Yes there is a much easier way :p.

I think the issue is his code placement, he is using $ir or $mem but at that time the vars havent been set just yet through any type of loop. If he looks past his else statement in his authenticate that we cant see I believe it has the $mem var set so he just needs to place his code within that loop and it should work fine

Posted (edited)
Try posting your entire authenticate file. I haven't looked at mc authenticate lately but im sure your issue is with the $ir variable

authenticate.php

 

<?php
session_start();
if(get_magic_quotes_gpc() == 0)
{
foreach($_POST as $k => $v)
{
 $_POST[$k]=addslashes($v);
}
foreach($_GET as $k => $v)
{
 $_GET[$k]=addslashes($v);
}
}

include "config.php";
include "language.php";
global $_CONFIG;
define("MONO_ON", 1);
require "class/class_db_{$_CONFIG['driver']}.php";
$db=new database;
$db->configure($_CONFIG['hostname'],
$_CONFIG['username'],
$_CONFIG['password'],
$_CONFIG['database'],
$_CONFIG['persistent']);
$db->connect();
$c=$db->connection_id;
$set=array();
$settq=$db->query("SELECT * FROM settings");
while($r=$db->fetch_row($settq))
{
$set[$r['conf_name']]=$r['conf_value'];
}
if ($_POST['username'] == "" || $_POST['password'] == "")
{
die("<h3>{$set['game_name']} Error</h3>
$nofill<br>
<a href=login.php>> Back</a>");
}
$uq=$db->query("SELECT userid FROM users WHERE login_name='{$_POST['username']}' AND `userpass`=md5('{$_POST['password']}')");
if ($db->num_rows($uq)==0)
{
die("<h3>{$set['game_name']} Error</h3>
$invalid<br>
<a href=login.php>> $lerrortry</a>");
}

if ($mem['confirmed']=0)

{
die("Your account is not active, check your email address including junk boxes.
<a href=login.php>> Back</a>");
}
else
{
$_SESSION['loggedin']=1;
$mem=$db->fetch_row($uq);
$_SESSION['userid']=$mem['userid'];
$IP = $_SERVER['REMOTE_ADDR'];
$IP=addslashes($IP);
$IP=mysql_real_escape_string($IP);
$IP=strip_tags($IP);
$db->query("UPDATE users SET lastip_login='$IP',last_login=unix_timestamp() WHERE userid={$mem['userid']}");
$db->query("UPDATE users SET active=1 WHERE userid={$mem['userid']}");
if($set['validate_period'] == "login" && $set['validate_on'])
{
$db->query("UPDATE users SET verified=0 WHERE userid={$mem['userid']}");
}
header("Location: index.php");
}


?>
Edited by boots
Posted

And this is why you spend so much time here asking for help.

Anyway, for the OP:

You need to make the query something the code can read. Try this:

i tried your code and i get this error

QUERY ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

Query was UPDATE users SET lastip_login='188.28.71.24',last_login=unix_timestamp() WHERE userid=

Posted
<?php
session_start();
if(get_magic_quotes_gpc() == 0)
{
foreach($_POST as $k => $v)
{
 $_POST[$k]=addslashes($v);
}
foreach($_GET as $k => $v)
{
 $_GET[$k]=addslashes($v);
}
}

include "config.php";
include "language.php";
global $_CONFIG;
define("MONO_ON", 1);
require "class/class_db_{$_CONFIG['driver']}.php";
$db=new database;
$db->configure($_CONFIG['hostname'],
$_CONFIG['username'],
$_CONFIG['password'],
$_CONFIG['database'],
$_CONFIG['persistent']);
$db->connect();
$c=$db->connection_id;
$set=array();
$settq=$db->query("SELECT * FROM settings");
while($r=$db->fetch_row($settq))
{
$set[$r['conf_name']]=$r['conf_value'];
}
if ($_POST['username'] == "" || $_POST['password'] == "")
{
die("<h3>{$set['game_name']} Error</h3>
$nofill<br>
<a href=login.php>> Back</a>");
}
$uq=$db->query("SELECT userid, confirmed FROM users WHERE login_name='{$_POST['username']}' AND `userpass`=md5('{$_POST['password']}')");
if ($db->num_rows($uq)==0)
{
die("<h3>{$set['game_name']} Error</h3>
$invalid<br>
<a href=login.php>> $lerrortry</a>");
}
else
{
$_SESSION['loggedin']=1;
$mem=$db->fetch_row($uq);
if ($mem['confirmed'] == 0)
{
echo "Your account has not been verified, please check all your email folders including your spam to verify your account";
return;
}
$_SESSION['userid']=$mem['userid'];
$IP = $_SERVER['REMOTE_ADDR'];
$IP=addslashes($IP);
$IP=mysql_real_escape_string($IP);
$IP=strip_tags($IP);
$db->query("UPDATE users SET lastip_login='$IP',last_login=unix_timestamp() WHERE userid={$mem['userid']}");
$db->query("UPDATE users SET active=1 WHERE userid={$mem['userid']}");
if($set['validate_period'] == "login" && $set['validate_on'])
{
$db->query("UPDATE users SET verified=0 WHERE userid={$mem['userid']}");
}
header("Location: index.php");
}


?>

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...