开发者

Notice: Undefined index: 2aad888f2b4ac316b016a9a0bda1c329 on line 16

Hello I am trying to make an email activation script in php and what you see above (2aad888f2b4ac316b016a9a0bda1c329) is this users unique activation key. What do you think the problem is? Here is my NEW code:

<?php

$host="localhost"; 
$username="root"; 
$password="power1"; 
$db_name="members"; 
$tbl_name="users";

$link  = mysql_connect($host, $username, $password)or die("cannot connect. Please contact us");
mysql_select_db($db_name)or die("cannot select DB. Please contact us");

$queryString = $_SERVER['QUERY_STRING'];

if(isset($_SESSION[$queryString])) {
开发者_JS百科$query = "SELECT * FROM users WHERE email='$_SESSION[$queryString]'";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
    if ($queryString == $row[activationkey]){
        echo "Congratulations! You have succesfully activated you account. You may now login.";

        $sql = ("UPDATE users SET activationkey='' AND status='activated' WHERE username=".$row['username']);

        if (!mysql_query($sql)) {
            die('Error: ' . mysql_error());
        }
    }
}
}


?>


$_SESSION['2aad888f2b4ac316b016a9a0bda1c329'] doesn't exist.

"but that cant exist becuase that key is not always going to be there those keys are random"

Then your error is in this line, trying to access that key anyway:

$uemail = $_SESSION["$queryString"]; 

Maybe you need to check with isset whether the key actually exists before accessing it, or change something in your program logic to prevent this case.


$host="localhost"; 
$username="root"; 
$password="power1"; 
$db_name="members"; 
$tbl_name="users";

$link  = mysql_connect($host, $username, $password)or die("cannot connect. Please contact us");
mysql_select_db($db_name)or die("cannot select DB. Please contact us");

$queryString = $_SERVER['QUERY_STRING'];

if(isset($_SESSION["$queryString")) {
    $query = "SELECT * FROM users WHERE email='$_SESSION["$queryString"]'";
    $result = mysql_query($query) or die(mysql_error());
    while($row = mysql_fetch_array($result)){
        if ($queryString == $row[activationkey]){
            echo "Congratulations! You have succesfully activated you account. You may now login.";

            $sql = ("UPDATE users SET activationkey='' AND status='activated' WHERE username=".$row['username']);

            if (!mysql_query($sql)) {
                die('Error: ' . mysql_error());
            }
        }
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜