Undefined index error
Posted: Thu Nov 19, 2009 9:09 pm
Hi i am working on registering and login users.
My registration works, and however it sends the person registering a confirmation email with a confirmation link that takes them to a confirmation page.
This page shows a success msg, indicating they have successfully registered and is now a memeber and needs to click on a link to login.
However at the point in time when the user clicks the confirmation link in the email this error msg comes up:
Notice: Undefined index: userid in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\eVoting\PHP\confirmation.php on line 30
The following is the confirmation code:
//connect to db
$id = $_GET['USERID'];
if ($_GET['USERID']==true) { the error is at this line 30
$query = mysql_query("SELECT * FROM USERS WHERE ACTKEY = '$id' LIMIT 1") or die(mysql_error());
$row = mysql_fetch_array($query);[/color]
if(mysql_num_rows($query) > 0) {
$userid = $row['USERID'];
$do = mysql_query("UPDATE USERS SET ACTIVATED = 1 WHERE USERID = '$userid' LIMIT 1") or die(mysql_error());
if($do) {
//messages if activation is successful or not
echo '
<p>Activation successful! You can now login!</p>
<p><a href="../html/ind.html">Click here</a> to goto the login page.</p>
';
} else {
echo '
<p>We are sorry, there appears to be an error processing your activation. Please try again later.</p>
';
}
} else {
echo '
<p>Sorry, your activation code was incorrect. Please try again.</p>
';
}
}//END TRUE
i have tried resolving it by using isset and replacing whats in the () with $id==true.
The same error still comes up, please help.
Note: i am no expert developer, so some simple terms or examples to resolve will be appreciated.
thank you...
My registration works, and however it sends the person registering a confirmation email with a confirmation link that takes them to a confirmation page.
This page shows a success msg, indicating they have successfully registered and is now a memeber and needs to click on a link to login.
However at the point in time when the user clicks the confirmation link in the email this error msg comes up:
Notice: Undefined index: userid in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\eVoting\PHP\confirmation.php on line 30
The following is the confirmation code:
//connect to db
$id = $_GET['USERID'];
if ($_GET['USERID']==true) { the error is at this line 30
$query = mysql_query("SELECT * FROM USERS WHERE ACTKEY = '$id' LIMIT 1") or die(mysql_error());
$row = mysql_fetch_array($query);[/color]
if(mysql_num_rows($query) > 0) {
$userid = $row['USERID'];
$do = mysql_query("UPDATE USERS SET ACTIVATED = 1 WHERE USERID = '$userid' LIMIT 1") or die(mysql_error());
if($do) {
//messages if activation is successful or not
echo '
<p>Activation successful! You can now login!</p>
<p><a href="../html/ind.html">Click here</a> to goto the login page.</p>
';
} else {
echo '
<p>We are sorry, there appears to be an error processing your activation. Please try again later.</p>
';
}
} else {
echo '
<p>Sorry, your activation code was incorrect. Please try again.</p>
';
}
}//END TRUE
i have tried resolving it by using isset and replacing whats in the () with $id==true.
The same error still comes up, please help.
Note: i am no expert developer, so some simple terms or examples to resolve will be appreciated.
thank you...