English 中文(简体)
在我点击提交之后,我为什么收到我的两封电子邮件。
原标题:Why am I receiving 2 emails from my form after I click submit
  • 时间:2011-11-18 07:36:12
  •  标签:
  • php
  • forms

我有问题。 当我点击提交所有细节时,我寄了mail,但问题是:我收到2份电子邮件、1份在我的盒子里、1份在我的间谍。

我确实不知道我对我的法典有什么错误。

任何建议都将受到高度赞赏。

这里是我的派任守则。

<?php

// get posted data into local variables
$EmailFrom = "webmaster";
$EmailTo = "[email protected]";
$Subject = "Contact us";
$name = $_POST[ name ];
$address=$_POST[ address ];
$month =$_POST[ month ];
$day =$_POST[ day ];
$year =$_POST[ year ];
$home =$_POST[ home ];
$mobile =$_POST[ mobile ];
$contact =$_POST[ contact ];
$relationship =$_POST[ relationship ];
$course =$_POST[ course ];
$hours =$_POST[ hours ];



// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $name;
$Body .= "
";
$Body .= "Address: ";
$Body .= $address;
$Body .= "
";
$Body .= "Month: ";
$Body .= $month;
$Body .= "
";
$Body .= "Day: ";
$Body .= $day;
$Body .= "
";
$Body .= "Year: ";
$Body .= $year;
$Body .= "
";
$Body .= "Home No.: ";
$Body .= $home;
$Body .= "
";
$Body .= "Mobile: ";
$Body .= $mobile;
$Body .= "
";
$Body .= "Contact Person: ";
$Body .= $contact;
$Body .= "
";
$Body .= "Relationship: ";
$Body .= $relationship;
$Body .= "
";
$Body .= "Course: ";
$Body .= $course;
$Body .= "
";
$Body .= "Hours: ";
$Body .= $hours;
$Body .= "
";

$headers = "From: ".$EmailFrom."" ;

// send email 
$success = mail($EmailTo, $Subject, $Body, $headers);

// redirect to success page 
if (mail($EmailTo, $Subject, $Body, $headers)){

header( "Location: application.php" );

}
?>
问题回答

简单回答:你寄来2封电子邮件:

// First E-Mail
$success = mail($EmailTo, $Subject, $Body, $headers);

// Second E-Mail
if (mail($EmailTo, $Subject, $Body, $headers)){
     header( "Location: application.php" );
}

仅删除第1行,或——如果需要收益价值的话——写上:

// Send E-Mail
$success = mail($EmailTo, $Subject, $Body, $headers);

if ($success){
     header( "Location: application.php" );
}

页: 1 您的法典有两度:

// send email 
$success = mail($EmailTo, $Subject, $Body, $headers);

// redirect to success page 
if (mail($EmailTo, $Subject, $Body, $headers)){

当然,邮件是两次发送的。

// redirect to success page
if (mail($EmailTo, $Subject, $Body, $headers)){

这一条件实际上将执行另一批货物,如果成功执行,将执行。

header( "Location: application.php" );

你两次打电话! 替换

// redirect to success page 
if (mail($EmailTo, $Subject, $Body, $headers)){

iii

if ($success){




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签