/    Sign up×
Community /Pin to ProfileBookmark

Login Script error

I’m trying to follow a login tutorial but I keep getting an error. The error I get is:

[code=php] Notice: Undefined index: id in c:inetpubwwwrootLoginregister.php on line 10

Notice: Undefined index: code in c:inetpubwwwrootLoginregister.php on line 11

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:inetpubwwwrootLoginregister.php on line 16
Your account could not be activated![/code]

And my php is:

[code=php]<?
/* Account activation script */

// Get database connection
$db = mysql_connect(“localhost”);
mysql_select_db(“login”);

// Create variables from URL.

$userid = $_REQUEST[‘id’];
$code = $_REQUEST[‘code’];

$sql = mysql_query(“UPDATE users SET activated=’1′ WHERE

userid=’$userid’ AND password=’$code'”);

$sql_doublecheck = mysql_query(“SELECT * FROM users WHERE

userid=’$userid’ AND password=’$code’ AND activated=’1′”);
$doublecheck = mysql_num_rows($sql_doublecheck);

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_form.html’;
}

?>[/code]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@JonaMay 01.2004 — [font=arial]Why are you using two MySQL queries? Why not just use one?[/font]

[code=php]<?
/* Account activation script */

// Get database connection
$db = mysql_connect("localhost");
mysql_select_db("login");

// Create variables from URL.

if(isset($_REQUEST["id"])){
$userid = $_REQUEST['id'];
} else {
$userid = "";
}
if(isset($_REQUEST["code"])){
$code = $_REQUEST['code'];
} else {
$code = "";
}

$sql = mysql_query("UPDATE users SET activated='1' WHERE

userid='$userid' AND password='$code'");

$sql_doublecheck = mysql_query("SELECT * FROM users WHERE

userid='$userid' AND password='$code' AND activated='1'");
$doublecheck = mysql_num_rows($sql_doublecheck);

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_form.html';
}

?>[/code]
×

Success!

Help @Haunted spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...