爆炸下拉值

时间:2011-05-12 23:01:40

标签: php

我之前发布了一个关于此的问题,但现在我遇到了一个我不知道的新问题。 这是HTML:

 <select name="contactname">
 <option></option>
 <option value="John Smith|Jsmith@email.com">John Smith</option>
 </select>

这是我现在得到的错误,我在发布页面上进行了更改。 解析错误:语法错误,第48行意外T_CONSTANT_ENCAPSED_STRING

这是发布页面:

</head>
<body>

<?php

$pickone = $_POST [pickone];
$dropone = $_POST [dropone];
$weight = $_POST [weight];
$length = $_POST [length];
$pallets = $_POST [pallets];
$pickupdate = $_POST [pickupdate];
$equipment = $_POST [equipment];
$loadtype = $_POST [loadtype];
$specialinformation = $_POST [specialinformation];
$commodity = $_POST [commodity];
$closetime = $_POST [closetime];
$deliverydate = $_POST [deliverydate];
$req = $_POST [req];
$contact = explode('|', $_POST[contactname]);


$header = "From: " . $contact[0] . " <" . $contact[1] . ">\r\n"; 
$subject= "New Load";
$from= "You";

$message = " 
Picks: $pickone
Drops: $dropone \n   
  PU Date: $pickupdate     Close Time: $closetime
 Del Date: $deliverydate \n
     Mode: $loadtype
Equipment: $equipment
   Length: $length
   Weight: $weight
  Pallets: $pallets
Commodity: $commodity \n

Requirements:
$req \n
Special Information: $specialinformation
Contact: $contactname[0]
";

mail("email.com", $subject, $message, $header");

?>

<p align="center">Thank You<br>
<input type="button" onclick="window.location.href='page.php';" value=" Post Another Load    " />
</p> 

</body>
</html>

请让我知道我错过了什么,因为如果我不试图爆炸联系人名称它工作正常。谢谢,

4 个答案:

答案 0 :(得分:1)

mail("email.com", $subject, $message, $header");

删除最后的引用:

mail("email.com", $subject, $message, $header);

此外,您确实要插入真实的电子邮件地址而不是“email.com”

在修复内容时​​,也会引用所有数组键 - 即$_POST['something']而不是$_POST[something],并使用error_reporting(E_ALL);启用通知

答案 1 :(得分:0)

不应该读一行:

Contact: $contact[0]

答案 2 :(得分:0)

在邮件结束时,您有一个额外的双引号 mail("email.com", $subject, $message, $header"); 应该 mail("email.com", $subject, $message, $header);

答案 3 :(得分:0)

在邮件行的末尾似乎有一个“错误”。

尝试将其更改为:mail("email.com",$subject,$message,$header);

除此之外我没有看到太多错误