0

以下是我网站的电子邮件验证码。

发送到用户邮箱的验证url如下: http://www.mywebsite.com/valid.php?confr=2774405&userid=2

额外说明

1)key是我数据库中的一列,它在注册时获得随机值。

2) 如果$verify == 1password_in_db=== user_entered_password,则登录发生在登录页面中。

<?php

    include 'connect.php';

    $query = mysql_query("SELECT verify,key FROM users WHERE id = '$_GET['userid']'");
    $details = mysql_fetch_assoc($query);
    $verify = $details['verify'];
    $confirm2 = $details['key'];

    if($verify == "1") {
        echo "Link Expired . Go to our login page :";
    } else {
        if (isset($_GET["confr"]) && isset($_GET["userid"])) {
            $confirm1 =$_GET["confr"];

            if($confirm1 == $confirm2) {
                mysql_query("INSERT INTO users (`verify`) VALUES ('1') WHERE id = '$_GET["userid"]' ;");
                echo "Thank You For Registering with us . Go to your LOGIN PAGE Here ";
            } else {
                echo "Invalid link ";
                echo "Go to your LOGIN PAGE Here ";
            }
        } //  of if isset
    } // of  else part
?>

connect.php 的代码

<?php
    mysql_connect("host", "username", "pass");  //connects to the server
    mysql_select_db("database_name");  //selects the database
?>

问题是它给了我一个空白屏幕。

4

3 回答 3

0

注意:插入语句没有位置 - 只要您不使用“插入到选择...”

http://dev.mysql.com/doc/refman/5.1/de/insert.html

于 2013-06-12T06:55:19.977 回答
0

尝试这个.......

<?php
include 'connect.php';

$user_id = $_GET["userid"];
$query = mysql_query("SELECT verify,key FROM users WHERE id = '$user_id'"); 
   while ($details = mysql_fetch_assoc($query)){ 
      $verify = $details['verify']; 
      $confirm2 = $details['key']; 
    }
if($verify == "1"){
    echo "Link Expired . Go to our login page :";
}
 else{
   if (isset($_GET["confr"]) && isset($_GET["userid"]))
 {
   $confirm1 =$_GET["confr"];
   if($confirm1 == $confirm2){

mysql_query("INSERT INTO users (`verify`) VALUES ('1') WHERE id = '$user_id'");

echo "Thank You For Registering with us . Go to your LOGIN PAGE Here ";
}
else {
echo "Invalid link ";
echo "Go to your LOGIN PAGE Here ";
    }
  } //  of if isset
} // of  else part

?>
于 2013-06-12T04:18:38.760 回答
0

我相信错误在于sql

每当我使用“WHERE”语句时,我总是将其定义为变量,试试这个

<?php
include 'connect.php';
$user_id = $_GET["userid"];
$query = mysql_query("SELECT verify,key FROM users WHERE id = '$user_id'");
$details = mysql_fetch_assoc($query);
$verify = $details['verify'];
$confirm2 = $details['key'];
if($verify == "1"){
echo "Link Expired . Go to our login page :";
}
else{
if (isset($_GET["confr"]) && isset($_GET["userid"]))
{
$confirm1 =$_GET["confr"];
if($confirm1 == $confirm2){

mysql_query("INSERT INTO users (`verify`) VALUES ('1') WHERE id = '$user_id'");

echo "Thank You For Registering with us . Go to your LOGIN PAGE Here ";
}
else {
echo "Invalid link ";
echo "Go to your LOGIN PAGE Here ";
}
} //  of if isset
} // of  else part

?>

此外,您在插入 sql 中有一个分号

于 2013-06-12T03:29:41.563 回答