我制作了一个表单,它会自动向提交该表单的用户发送电子邮件。如果您提交该表单(它将被发布到 mysql 数据库中),将会(自动)创建一个 id,我想在电子邮件中发送这个 id,但我现在无法让它工作。有人可以帮助我吗?
<?php
define('NoDirectAccess', TRUE);
include_once("mysqlconfig.php");
//function which gets the ip
function getRealIpAddr()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}
$ip = getRealIpAddr();
$ip = ip2long($ip);
$ipun = long2ip($ip);
error_reporting(0);
$checkIP = mysql_query("SELECT * FROM main_applications WHERE ip_adres=$ip");
$getIDbyIP = mysql_query("SELECT id FROM main_applications WHERE ip_adres=$ip");
$idRedirect = mysql_fetch_assoc($getIDbyIP);
$idmail = $idSeparator['id'];
$to = strip_tags($_POST['e_mail']);
$subject = "MedievalRP Application - " . strip_tags($_POST['first_name']) . " ";
$headers = "From: noreply@medievalrp.com\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['e_mail']) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body><center>';
$message .= '<img src="http://potterp.com/solli/images/logo.png" alt="MedievalRP Logo" />';
$message .= '<br>Congratulations, you <strong style="color:green">successfully</strong> applied on MedievalRP.com,your application will be reviewed by an admin as soon as possible. You will receive an email when your application has been reviewed. On <a href="http://medievalrp.com/status.php?id='.$idSeparator['id'].'">this page</a> you can check your application status. Your application details will are listed down here: <br><br>';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr style='background: #eee;'><td><strong>Apply ID:</strong> </td><td><b>".$idSeparator['id']. "</b></td></tr>";
$message .= "<tr><td><strong>Minecraft Name:</strong> </td><td>" . strip_tags($_POST['minecraft_name']) . "</td></tr>";
$message .= "<tr><td><strong>Firstname:</strong> </td><td>" . strip_tags($_POST['first_name']) . "</td></tr>";
$message .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($_POST['e_mail']) . "</td></tr>";
$message .= "<tr><td><strong>Skype:</strong> </td><td>" . strip_tags($_POST['skype']) . "</td></tr>";
$message .= "<tr><td><strong>Experience</strong> </td><td>" . $_POST['experience'] . "</td></tr>";
$message .= "<tr><td><strong>Extra Notes</strong> </td><td>" . $_POST['extra_notes'] . "</td></tr>";
$message .= "</table></center>";
$message .= "<br><b><strong>Note: You can't reply to this e-mail address. For questions contact: info@medievalrp.com</strong></b>";
$message .= "</body></html>";
?>
<?php
if(mysql_num_rows($checkIP) == 1){
echo '<b><center style="color:red; margin-top:5px;">You already applied on this IP address('. $ipun.') You will be redirected to the status page.</center></b> <meta HTTP-EQUIV="REFRESH" content="3; url=/status.php?id='.$idRedirect['id'].'">';
}
if ($_POST['mysubmit']){
if (empty($_POST['minecraft_name'])) {
echo '<center><div style=" border-radius:5px;font-size:15px;background-color:#B43104;width:300px;height:25px;margin-left:100px;font-weight:bold;color:#FFFFFF;text-align:center;">Fill in your minecraftname</div></center>';
}
if (empty($_POST['first_name'])) {
echo '<center><div style="border-radius:5px; font-size:15px;background-color:#B43104;width:300px;height:25px;margin-left:100px;font-weight:bold;color:#FFFFFF;text-align:center;">Fill in your firstname</div></center>';
}
if (empty($_POST['e_mail'])) {
echo '<center><div style="border-radius:5px; font-size:15px;background-color:#B43104;width:300px;height:25px;margin-left:100px;font-weight:bold;color:#FFFFFF;text-align:center;">Fill in your e-mail</div></center>';
}
if (empty($_POST['skype'])) {
echo '<center><div style="border-radius:5px; font-size:15px;background-color:#B43104;width:300px;height:25px;margin-left:100px;font-weight:bold;color:#FFFFFF;text-align:center;">Fill in your skype</div></center>';
}
if (empty($_POST['experience'])){
echo '<center><div style=" border-radius:5px;font-size:15px;background-color:#B43104;width:300px;height:25px;margin-left:100px;font-weight:bold;color:#FFFFFF;text-align:center;">Fill in your experience</div></center>';
}
else {
mysql_query("INSERT INTO main_applications (ID, minecraft_name, firstname, e_mail, skype, experience, extra_notes, ip_adres)VALUES('DEFAULT','".$_POST['minecraft_name']."','".$_POST['first_name']."','".$_POST['e_mail']."','".$_POST['skype']."','".$_POST['experience']."','".$_POST['extra_notes']."', '".$ip."')");
$getId = mysql_query("SELECT * FROM main_applications WHERE minecraft_name = '".mysql_real_escape_string($_POST['minecraft_name'])."'");
$idSeparator = mysql_fetch_assoc($getId);
mail($to, $subject, $message, $headers);
echo '<div style="margin-top:20px;font-size:15px;border-radius:5px;padding:5px 5px;background-color:#298A08;width:500px;height:55px;margin-left:100px;font-weight:bold;color:#FFFFFF;text-align:center;">Your apply has been sent. A copy of your application will be send to your email: '; echo '<b style="color:#D8D8D8;">'; echo $_POST['e_mail']; echo'</b>'; echo '<br>Your apply id = '.$idSeparator['id'].'</div>';
}
}
?>
提前致谢!!
沃特