Jump to content


Photo

Account Activation


  • This topic is locked This topic is locked
2 replies to this topic

#1 anthonydamasco

anthonydamasco
  • Members
  • PipPipPip
  • Advanced Member
  • 92 posts

Posted 31 July 2006 - 02:41 PM

I cannot get the activation to work, anyone have any ideas? Always says "Cannot be activated"




<?php

// connect to database
$conn = mysql_connect("localhost","www2","accuoffice");

//select the database
$db = mysql_select_db("accu") or die( "Unable to select database");

// Create variables from URL.

$userid = $_REQUEST['id'];
$code = $_REQUEST['code'];

//insert the values
$sql = "UPDATE users SET activated='1' WHERE userid='$userid' AND password='$code'";
$double_sql = "SELECT * FROM users WHERE userid='$userid' AND password='$code' AND activated='1'";
mysql_query($sql);
mysql_query($Double_sql);
$doublecheck = mysql_num_rows($sql_doublecheck);


mysql_close();


if($doublecheck == 0){
    echo "<strong><font color=red>Your account could not be activated!</font></strong>";
} elseif ($doublecheck > 0) {
    echo "<strong>Your account has been activated!</strong> You may login below!<br />";
    include 'login.html';
}

?>


#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 31 July 2006 - 02:44 PM

You code not working as you are not referencing this line:
mysql_query($Double_sql);
You'll want to do this:
$sql_doublecheck = mysql_query($Double_sql);


#3 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 31 July 2006 - 03:02 PM

Maybe you wanna try this, I haven't tried it but it should works.
<?php

// connect to database
$conn = mysql_connect("localhost","www2","accuoffice");

//select the database
$db = mysql_select_db("accu") or die( "Unable to select database");

// Create variables from URL.

$userid = $_GET['id'];
$code = $_GET['code'];

$query = "SELECT * FROM users WHERE userid='$userid' AND password='$code' LIMIT 1";
$result = mysql_query($query) or die("There's some problem with the query.");
$row = mysql_fetch_assoc($result);

if (!$row)
{
	echo "<strong><font color=red>Your account could not be activated!</font></strong>";
}
elseif ($row['activated'] == 0)
{
	echo "<strong>Your account has been activated!</strong> You may login below!<br />";
}
else
{
	mysql_query("UPDATE users SET activated='1' WHERE userid='$userid' AND password='$code'");
    echo "<strong>Your account has been activated!</strong> You may login below!<br />";
}

?>


Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users