PHP编程非常新,但是我试图将两个进程合并在一起。其中一个我找到了源代码,而第二个却找到了我手头的一个工作脚本。在这样做时,我不知道如何解决该问题。从我的表单发布到此php文件时,我收到内部服务器错误500消息。目标是收集购物车信息并将数据解析为电子邮件。原始代码默认使用贝宝(Paypal)流程,但我的目标是模拟采购订单而不是购买。
我一直在处理我的原始代码和文件,并调整了执行顺序。我似乎认为问题出在代码块在订单详细信息下,消息结尾之前的位置,但不确定如何解决。
<?php
/* Original Source ATN Simple Cart*/
if(isset($_REQUEST["proceed"]))
{
/***********************************************************************/
/* Data Parsing Setup and Validation */
/***********************************************************************/
//Loading the config.xml file
if(file_exists("../config.xml"))
{
$config_file="../config.xml";
}
else
if(file_exists("../atn-simple-cart/config.xml"))
{
$config_file="../atn-simple-cart/config.xml";
}
else
{
die("No config.xml file found");
}
//Initializing the config settings
$xml_config = simplexml_load_file($config_file);
// Declare HTML Form, Post Method Variables
$yourname = check_input($_POST['yourname'], "Enter your name");
$email = check_input($_POST['email']);
$location = check_input($_POST['location']);
$comments = check_input($_POST['comments'], "Write your comments");
/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
show_error("E-mail address not valid");
}
/***********************************************************************/
/* Email Setup */
/***********************************************************************/
/* Set e-mail recipient */
$recipientemail = "recipient@contact.com";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers = "From: shop@company.com" . "\r\n" ;
/* Let's prepare the message for the e-mail */
$message = "Hello!
A new form request has been submitted by:
Name: $yourname
E-mail: $email
Comments:
$comments
Order Details:
"Ordered items: " . stripslashes($_REQUEST["products_list"])."\n\n".
"Total value: ".$xml_config->configuration->currency_symbol.$_REQUEST["products_value"]
End of message
";
/* Send the message using mail() function */
mail($recipientemail, "Shop Order: " . $yourname . "(" . $location . ")", $message, $headers);
/* Redirect visitor to the thank you page */
header('Location: thanks.htm');
exit();
?>
<script>
parent.document.location.href="<?php echo $paypal_link;?>";
</script>
<?php
}
?>
任何帮助找出导致问题的原因或解决方法的帮助。