Jump to content

Archived

This topic is now archived and is closed to further replies.

anthonydamasco

Account Activation

Recommended Posts

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




[code=php:0]
<?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';
}

?>
[/code]

Share this post


Link to post
Share on other sites
You code not working as you are not referencing this line:
[code]mysql_query($Double_sql);[/code]
You'll want to do this:
[code]$sql_doublecheck = mysql_query($Double_sql);[/code]

Share this post


Link to post
Share on other sites
Maybe you wanna try this, I haven't tried it but it should works.
[code]<?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 />";
}

?>[/code]

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.