anthonydamasco Posted July 31, 2006 Share Posted July 31, 2006 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] Link to comment https://forums.phpfreaks.com/topic/16108-account-activation/ Share on other sites More sharing options...
wildteen88 Posted July 31, 2006 Share Posted July 31, 2006 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] Link to comment https://forums.phpfreaks.com/topic/16108-account-activation/#findComment-66386 Share on other sites More sharing options...
hackerkts Posted July 31, 2006 Share Posted July 31, 2006 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] Link to comment https://forums.phpfreaks.com/topic/16108-account-activation/#findComment-66395 Share on other sites More sharing options...
Recommended Posts