我有一個表格,客戶填寫個人數據,並作出有關服務的選擇。因此,利用$ _GET函數檢索該表單的信息,進行一些基本的數學計算並顯示所有信息,以便客戶可以預覽訂單,然後點擊「發送」以確認作業。PHP郵件:頁面內容到郵件
我需要通過郵件向我發送預覽訂單,但我不知道如何發送所有。我知道如何從表單中檢索數據然後發送,但不知道如何發送這些變量。
FORM
// I am omitting elements to make this shorter
<select name="Amount">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
預覽整理
$price = 5;
// I am omitting elements to make this shorter
// here I do some math
$Amount = $_GET['Amount'];
// check value and select appropriate item
if ($Amount== "1") {
$extra = "1";
}
elseif ($Amount == "2") {
$extra = "2";
}
elseif ($Amount == "3") {
$extra = "3";
// here is the order preview and this is what I need to email to myself
// the customer should look this preview and then HIT a confirm buttom to get this sent
<?php echo $Name;?><br>
<?php echo $Address;?><br>
<?php echo $E-mail;?><br>
<?php echo $Phone;?><br>
Your order: <?php echo $extra . " " . "products, for a total of" . " " . ($price * $extra); ?>
--------------------最終版本------- --------感謝你們所有人!
我將只使用2場,以縮小代碼
//形式 - 用戶條目他的數據
<form method="get" id="order" action="order-info.php">
<h1>Personal Info</h1>
<p>name: <input name="name" type="text" /></p>
<p>email: <input name="surname" type="text" /></p>
<INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Continue">
</form>
//訂購預覽 - 在這裏,用戶可以預覽
- 他的所有數據和產品有關的選擇的確認訂單<?php session_start(); ?>
<?php
// get info personal
$Name = $_GET['name'];
$Email = $_GET['email'];
?>
// Now I echo the info
<h2><?php echo $Name . " " . $Email ; ?><br></h2>
<?php
// here's where the magic is done thanks to Sheldon Ferns!
$_SESSION['customerInfo']['name'] = $Name;
$_SESSION['customerInfo']['email'] = $Email;
?>
// having stored all the info in a session I proceed to send it to the email function. That weird name is because I read you should avoid naming your email process file with predictable names like mail.php, this increases protection against spammers.
<form method ="POST" action = "xljkadf.php">
<INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Confirm Order">
// MAIL過程之前
喜,一些投入.. 1.under MAIL過程 - 我看到二硝基甲苯任何使用foreach($ _ REQUEST as $ fields => $ value).... 2.我建議你使用header('Location:http://www.yoursite.com/thank-you.html');出口();之後的郵件()函數,而不是window.location.href –