gpt4 book ai didi

java - 已发送带有确认链接的 PHP 电子邮件,但确认链接不起作用

转载 作者:行者123 更新时间:2023-12-02 07:50:52 25 4
gpt4 key购买 nike

我正在生成一封电子邮件并在一个文件中发送,该电子邮件中的一个链接链接到我的确认页面,然后该页面应根据用户所做的选择在数据库表中移动用户名。问题是我从确认页上什么也没有得到,即使我只使用一个简单的打印语句而没有其他任何东西。我一直在试图找出答案,但无济于事,错误报告也返回空白。这里有两个文件:

email.php(完全有效)

<?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 .= "\n\nClick on the following link to give $name permission to be the Head Coach of the $team_name (Located in the ZIP code $zip_code).\n\n";
$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 .= "\n\nClick on the following link to give $name permission to be a Score Keeper for the $team_name (Located in the ZIP code $zip_code).\n\n";
$message.="http://web.***.***/~***/confirmation.php?key=$confirm"; // way to prevent no spam, dont use txt

}

$headers = "From: ***";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$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();
?>

确认.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";
}

?>

我已经浪费了大量的时间来尝试错误检查,这是一种浪费,所以希望更多的眼睛能够帮助更快地解决问题。任何帮助或建议都会很棒。提前致谢

最佳答案

if(sent) >>should be>> if($sent)

关于java - 已发送带有确认链接的 PHP 电子邮件,但确认链接不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10248175/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com