dpyic24480 2012-04-20 14:27
浏览 38

PHP电子邮件已发送确认链接但确认链接无效

I have an email being generated and sent in one file, a link in that email links to my confirmation page which then should move the users name around database tables according to choices they have made. Problem is i am getting nothing from the confirmation page at all, even when i use just a simple print statement and nothing else. I have been trying to figure it out but to no avail and error reporting is returning blank as well. here at the two files:

email.php (which fully works)

<?php 

$link= mysql_connect(...............); //Establish connection to the MySQL server

if (!$link) {
die('Could not connect: ' . mysql_error());
}

mysql_select_db(.....);

$confirm = md5(uniqid(rand()));
$position = $_POST['position'];
$team_name = $_POST['team_name'];
$zip_code = $_POST['zip_code'];
$userId = $_POST['userId'];

$s=mysql_query("SELECT Coach, TeamId FROM TEAM WHERE TEAM.Name = '$team_name' AND TEAM.Zip     ='$zip_code'") OR die ("Error 1"); //Get result from query

while($row=mysql_fetch_assoc($s))
{ 
$coachId = $row['Coach'];
$teamId = $row['TeamId'];   
}

$l=mysql_query("SELECT Name, Email FROM USER WHERE USER.UserId = '$userId'") OR die ("Error 3");     //Get result from query

while($row = mysql_fetch_assoc($l))
{
$user_name = $row['Name'];
$user_email = $row['Email'];
}

$q=mysql_query("SELECT Name, Email FROM USER WHERE USER.UserId = '$coachId'") OR die ("Error 4"); //Get result from query

while($coach=mysql_fetch_assoc($q))
{
 $to = $coach['Email']; 
 $name = $user_name;
 $subject = "Scoutlet $position Request for The $team_name"; 

 if($position == "Head Coach")
 {
    $message = "$name has requested to become the Head Coach for the $team_name."; 
    $message .= "

Click on the following link to give $name permission to be the Head Coach of the $team_name (Located in the ZIP code $zip_code).

";
    $message .="<a href=\"http://web.***.***/~***/confirmation.php?key=$confirm\">Click Here to make $name the Head Coach</a>";
 }
 else
 {
     $message = "$name has requested to become a Score Keeper for the $team_name.";
     $message .= "

Click on the following link to give $name permission to be a Score Keeper for the $team_name (Located in the ZIP code $zip_code).

";
     $message.="http://web.***.***/~***/confirmation.php?key=$confirm"; // way to prevent no spam, dont use txt

 }

 $headers = "From: ***"; 
 $headers .= 'MIME-Version: 1.0' . "
";
 $headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";
 $sent = mail($to, $subject, $message, $headers) ; 

 if($sent)
 {
    print "sent"; 
 }
 else 
 {
    print "fail"; 
 }
 }
 $sql=mysql_query("INSERT INTO CONFIRMATION(ConfirmationNumber, UserId, Email, TeamId, TeamName, Position)VALUES('$confirm', '$userId','$user_email','$teamId', '$team_name', '$position')") OR die ("Error 2"); //Get result from query

 mysql_close();
 ?> 

confirmation.php

<?
  ini_set('display_errors',1); 
 error_reporting(E_ALL);
$confirm = $_GET['key'];

$link= mysql_connect(***********); //Establish connection to the MySQL server

if (!$link)
{
    die('Could not connect: ' . mysql_error());
}
echo "connect4e";

mysql_select_db(**********);

$sql1=mysql_query("SELECT * FROM CONFIRMATION WHERE ConfirmationNumber ='$confirm'") OR die ("Fail 1");

    while($row=mysql_fetch_assoc($sql1))
    {
        $userId= $row['UserId'];
        $user_email = $row['Email'];
        $teamId = $row['TeamId'];
        $team_name = $row['TeamName'];
        $position= $row['Position'];
    }

    $sql2= mysql_query("INSERT INTO USER (Role) VALUES ('$position') WHERE UserId ='$userId'") OR die ("Fail 2");

    if($position =="Head Coach")
    {
        $sql3= mysql_query("INSERT INTO TEAM (Coach) VALUES ('$userId') WHERE TeamId ='$teamId'") OR die ("Fail 3a");
    }
    else
    { // do a check earlier on to see if the user is already a score keeper for that team
        $sql3= mysql_query("INSERT INTO SCOREKEEPS_FOR (ScoreKeeper, Team) VALUES ('$userId', '$teamId')") OR die ("Fail 3b");
    }

    $to= $user_email;           
    $subject="Welcome to Our Site";
    $headers = "From: ******"; 
    $message="Congratulations, you have been confirmed as a $position for The $team_name.";

    $sent = mail($to,$subject,$message,$header);
    if(sent)
    {
        $sql4=mysql_query("DELETE FROM CONFIRMATION WHERE ConfirmationNumber = '$confirm'") OR die ("Fail 5");
    }
    else
    {
        print "fail";
    }

?>

I've already killed a ton of time just trying to error check which was a waste so hopefully more eyes will help solve it faster. any help or suggestions would be great. thanks in advance

  • 写回答

3条回答 默认 最新

  • dsgk0386 2012-04-20 14:36
    关注
    if(sent) >>should be>> if($sent)
    
    评论

报告相同问题?

悬赏问题

  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能