PHP邮件发送,但不正确

时间:2015-12-03 18:15:16

标签: php

我的PHP邮件正在向我发送邮件,并且昨天正在100%工作,但今天它发送了,但每个字段都是第一个发送的。例如布局是:

Hi my name is, $name.

I would like to rent an apartment from, $apartment.

My VEI Bank account number is, $account.

Will you also check to see if our firm is purchasing from your commercial for the 10% discount? I work at, $cname.

Please contact me back via email, $email.

但是,电子邮件看起来像这样:

Hi my name is, 1.

I would like to rent an apartment from, 1.

My VEI Bank account number is, 1.

Will you also check to see if our firm is purchasing from your commercial for the 10% discount? I work at, 1.

Please contact me back via email, 1

如果你想查看代码页面是synergy.x10host.com/business.php

提前感谢!

修改



<?php

$to = 'synergy.mi@veinternational.org';
$subject = 'Commercial Purchase!';

$cname = isset($_POST['cname']);
$cemail = isset($_POST['cemail']);
$bank = isset($_POST['bank']);
$ceo = isset($_POST['ceo']);
$sqft = isset($_POST['sqft']);

$message = <<<EMAIL

Hello, my name is, $ceo, and I am the CEO of $cname.

We would like to purchase $sqft sq ft of commercial from you for a total of $$sqft.

Our Firm bank account number is, $bank.

Thanks in advance and please contact us back at $cemail.

EMAIL;

$header = "From: $cemail";


if($_POST){
    if($cname == '' || $cemail == '' || $bank == '' || $ceo == '' || $sqft == ''){
        $feedback = 'Please fill out all of the fields.';
    }else{
        mail ( $to, $subject, $message, $header);
        $feedback = 'Thank you for purchasing a apartment through us!';
    }
}

?>

<!DOCTYPE html>
<html>
<!--CSS Style and Title-->
	<head>
		<title>Synergy | Home</title>
		<link rel="stylesheet" type="text/css" href="extra/style-bus.css">
		<link rel="shortcut icon" href="extra/images/synergy.png"
	</head>

	<body>
		<!--<div id="view-cart">
			<a href="https://portal.veinternational.org/buybuttons/us06303/cart/">View Cart</a>
		</div>-->
		<div id="logonav">
			<a href="index.html"><img src="extra/images/synergy.png" width="40px"></a>
		</div>
		<nav>
			<a href="index.html">Home</a>
			<a href="services.html">Services</a>
			<a href="contact.php">Contact Us</a>
			<a href="#aboutus">About Us</a>
		</nav>
<!--Body of Page-->
        <div id="bus-head">
        	<p align="center"><font size="9">BUSINESS</font></p>
        </div>
        <div id="bus-com">
        	<p id="feedback"><?php echo $feedback; ?></p>
       		<form action="?" method="post">
       			<ul>
       				<li>
       					<label for="cname">Company Name: </label>
       					<input type="text" id="cname" name="cname" required />
       				</li>
       				<li>
       					<label for="cemail">Company Email: </label>
       					<input type="text" name="cemail" id="cemail" required />
       				</li>
       				<li>
       					<label for="bank">Firm Bank Number: </label>
       					<input type="text" name="bank" id="bank" required />
       				</li>
       				<li>
       					<label for="ceo">CEO Name: </label>
       					<input type="text" name="ceo" id="ceo" required />
       				</li>
       				<li>
       					<input type="text" name="sqft" id="sqft" required />
       					<label for="sqft">Sq ft x $1.00 per Sq ft</label>
       				</li>
       				<li>
       					<input type="submit" value="Submit" />
       				</li>
       			</ul>
        	</form>        	
        </div>
        <!--Footer/Extra Nav/Copyright-->
	<footer>
		<p align="center">
			<small><a href="index.html">Home</a> | <a href="contact.php">Contact Us</a> | <a href="services.html">Services</a> | <a href="#">About Us</a><br/>This is an official <font color="grey"><a href="https://veinternational.org/">Virtual Enterprises International</a></font> firm website and is for educational purposes only. ||  2015-2016 | Synergy, Inc.</small>
		</p>
	</footer>
	</body>
</html>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:2)

您将1作为输出的原因是因为布尔值(true)正在转换为字符串。在PHP中转换为字符串的布尔true1

如果查看PHP手册,isset将返回一个布尔值。如果您想在设置之前检查并查看该值是否存在,则可以使用以下内容:

$cname = isset($_POST['cname']) ? $_POST['cname'] : "Some other text";
$cemail = isset($_POST['cemail']) ? $_POST['cemail'] : "Some other text";
$bank = isset($_POST['bank']) ? $_POST['bank'] : "Some other text";
$ceo = isset($_POST['ceo']) ? $_POST['ceo'] : "Some other text";
$sqft = isset($_POST['sqft']) ? $_POST['sqft'] : "Some other text";

这样,isset检查是否设置了$ _POST ['cname']。如果已设置,则使用该值。否则,它会使用您提供的其他一些默认文本。

答案 1 :(得分:0)

Isset返回布尔值。这就是你发送&#39; 1&#39;在你的邮件中

$cname = isset($_POST['cname']);
$cemail = isset($_POST['cemail']);
$bank = isset($_POST['bank']);
$ceo = isset($_POST['ceo']);
$sqft = isset($_POST['sqft']);