我已爲多個字段的網站創建聯繫表單。清除按鈕完美地工作,但是當我點擊提交按鈕時,我無意中下載了與網頁相關聯的.php文件,而不是將具有訂單表格的電子郵件發送到指定地址。我在這裏真的很陌生,所以任何幫助將不勝感激。PHP在線訂單表問題
<?php
$field_name = $_POST['cf_name'];
$field_email = $_POST['cf_email'];
$field_quantity = $_POST['cf_quantity'];
$field_which = $_POST['cf_which'];
$field_size = $_POST['cf_size'];
$field_school = $_POST['cf_school'];
$field_college = $_POST['cf_college'];
$field_message = $_POST['cf_message'];
$mail_to = '[email protected]';
$subject = 'TShirt Order - xxx.Org '.$field_name;
$body_message = 'From: '.$field_name."\n";
$body_message .= 'E-mail Address: '.$field_email."\n";
$body_message .= 'Quantity of Shirts: '.$field_quantity."\n";
$body_message .= 'Shirt Style(s): '.field_which."\n";
$body_message .= 'Size(s): '.field_size."\n";
$body_message .= 'School: '.field_school."\n";
$body_message .= 'College: '.field_college."\n";
$body_message .= 'Message: '.$field_message;
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for placing an order with xxx.Org. We will contact you shortly.');
window.location = 'contact_page.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to [email protected]');
window.location = 'contact_page.html';
</script>
<?php
}
?>
的HTML代碼:
<form action="contact.php" method="post">
Full Name:
<input type="text" name="cf_name">
<br />
<br />
Email Address:
<input type="text" name="cf_email">
<br />
<br />
Quantity of TShirts:
<input type="numeric" name="cf_quantity">
<br />
<br />
Which Style(s)?
<input type="text" name="cf_which">
<br />
<br />
Size(s):
<input type="text" name="cf_size">
<br />
<br />
Name of School:
<input type="text" name="cf_school">
<br />
<br />
Name of College:
<input type="text" name="cf_college">
<br />
<br />
<input type="submit" value="Send">
<input type="reset" value="Clear">
</form>
不會與你具有所有的問題有所幫助,但' SpoonNZ 2012-03-11 22:29:02
如果你要創建一個hello.php頁面,消除了表單和contact.php頁面之間的任何交互,hello.php會以同樣的方式行爲嗎? – dldnh 2012-03-11 22:29:27
這很可能是一個配置問題,你自己安裝了PHP嗎? – Filype 2012-03-11 22:29:46