douluo7366 2015-12-09 20:13
浏览 104

php确认电子邮件脚本忽略验证步骤

I downloaded a neswletter subscription php script from here: http://www.plus2net.com/php_tutorial/newsletter.php

The script should check if a subsriber already has confirmed his email address. For some reason, this check is always ignored... I do not succeed to display the error message "You have already confirmed your subscription." which is in the script.. I herewith copy the script. Does anyone see what I am missing here? The script comes with 2 tables: nl_confirm with fields confirm_id, email_id, email, word, dtt and status (which contains the list of users which did not yet confirm their email) nl_email with fields email_id, email and status, which contains all subscribers. Status is F if not confirmed. A when confirmed...

this is the confirm.php script:

<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title></title>
<META NAME="DESCRIPTION" CONTENT=" ">
<META NAME="KEYWORDS" CONTENT="">
<link rel="stylesheet" href="style.css" type="text/css">
</head>

<body>
<?Php
require "config.php";
$confirm_id=$_GET['confirm_id'];

$count=$dbo->prepare("
    select confirm_id,email,email_id,word,status,UNIX_TIMESTAMP(dtt) as stored_time 
    from nl_confirm where confirm_id=:confirm_id");
$count->bindParam(":confirm_id",$confirm_id,PDO::PARAM_INT,4);

if($count->execute()){
    $row = $count->fetch(PDO::FETCH_OBJ);
    if($row->confirm_id >0){
        ///////// checking the input data with record ////////////
        $flag='OK';
        $msg='';
        if($row->email_id <> $_GET['email_id']){
            $flag='NOTOK';
            $msg.='<br>Wrong Email address ';
        }

        if($row->word  <> $_GET['token']){
            $flag='NOTOK';
            $msg.='<br>Wrong Token';
        }

        if($row->email <> $_GET['email']){
            $flag='NOTOK';
            $msg.='<br>Wrong Email address ';
        }
        $present_time=time();
        $stored_time=$row->stored_time;
        //echo 'stored time : '.$row->stored_time.'<br>Present time : '. $present_time.'<br>' ;
        if(($present_time-$stored_time)>300){ 
            //// Within 300 seconds user needs to confirm subscription , you can adjust this duration ////
            $flag='NOTOK';
            $msg.='<br>It is too long. Your confirmation time expired. <a href=subscribe.php>Subscribe again</a> ';
        }

        if($row->status == 'A'){
            $flag='NOTOK';
            $msg.='<br>You have already confirmed your subscription. ' ;
        }

        if($flag=='OK'){
            $count1=$dbo->prepare("update nl_email set status='A' where email_id=$row->email_id");
            if($count1->execute()){
                $count2=$dbo->prepare("delete from  nl_confirm where confirm_id=$row->confirm_id");
                $count2->execute();
                echo "Thank you for confirming your email address. You are a subscriber of our newsletter script.
    <br> Any time you can unsubscribe by visiting a link in your newsletter. ";
            }
        }
        else{echo $msg.'<br>';}

        //////////// end of checking data /////////////
    }else{ // if condition to check confirm_id > 0
        echo " We don't have any record of pending confirmation against your email address,<br>
     you can check by <a href=subscribe.php>subscribing</a> again or contact site admin.";
    } // end of if else to check confirm_id >0
}else{ // if execute() fails 

    print_r($dbo->errorInfo()); 
}

//////////////////////////////////////////////

echo "</body></html>";
  • 写回答

1条回答 默认 最新

  • doufan6033 2015-12-09 20:43
    关注

    Have you tried removing the two ** at the start and end of this part of the code?

    **if($row->status == 'A'){
    $flag='NOTOK';
    $msg.='<br>You have already confirmed your subscription. ' ;
    }**
    
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题