-3
我想問你一個幫助。我使用簡單的時間段預訂日曆,一切工作正常(詳細信息正確地傳輸到msql數據庫中),但我無法將所有表單詳細信息發送到我的電子郵件以及客戶電子郵件中以進行確認。使用php發送表單信息到電子郵件
我只能發送前。地址信息或名稱信息,但不能同時發送,也不能發送所有詳細信息。你能幫我麼。非常感謝你們的幫助!
book_slots.php:
<?php
include('php/connect.php');
include('new.php');
if(isset($_POST['slots_booked'])) $slots_booked = mysqli_real_escape_string($link, $_POST['slots_booked']);
if(isset($_POST['name'])) $name = mysqli_real_escape_string($link, $_POST['name']);
if(isset($_POST['address'])) $address = mysqli_real_escape_string($link, $_POST['address']);
if(isset($_POST['email'])) $email = mysqli_real_escape_string($link, $_POST['email']);
if(isset($_POST['phone'])) $phone = mysqli_real_escape_string($link, $_POST['phone']);
if(isset($_POST['booking_date'])) $booking_date = mysqli_real_escape_string($link, $_POST['booking_date']);
if(isset($_POST['cost_per_slot'])) $cost_per_slot = mysqli_real_escape_string($link, $_POST['cost_per_slot']);
$booking_array = array(
"slots_booked" => $slots_booked,
"booking_date" => $booking_date,
"cost_per_slot" => number_format($cost_per_slot, 2),
"name" => $name,
"address" => $address,
"email" => $email,
"phone" => $phone
);
$explode = explode('|', $slots_booked);
foreach($explode as $slot) {
if(strlen($slot) > 0) {
$query = "INSERT INTO bookings (date, start, name, address, email, phone) VALUES ('$booking_date', '$slot', '$name', '$address', '$email', '$phone')";
$result = mysqli_query($link, $query) or die(mysqli_error($link));
} // Close if
} // Close foreach
header('Location: thankyou.php');
?>
connect.php:
<?php
// Make a MySQL Connection
$host="my host";
$user="db_xxx";
$password="mypasswoe";
$db = "db_xxx";
$link = mysqli_connect($host, $user, $password);
mysqli_select_db($link, $db) or die(mysql_error());
?>
new.php:
<?php
//if "email" variable is filled out, send email
if (isset($_REQUEST['email'])) {
//Email information
$admin_email = "[email protected]";
$email = $_REQUEST['email'];
$subject = "Booking Confirmation";
$comment = "Hi, \n\n Thank you for joining \n\n
Regards Site Admin \n\n";
//send email
mail($email, "$subject", "$comment", "From:" . $admin_email);
//Email response
echo "Thank you for contacting us!";
}
//if "email" variable is not filled out, display the form
else {
?>
<form method="post">
Email: <input name="email" type="text" /><br />
Subject: <input name="subject" type="text" /><br />
Message:Your Reservation has been made. Please check reservation detail below:<br />
<textarea name="comment" rows="15" cols="40"></textarea><br />
<textarea name="name" rows="15" cols="40"></textarea><br />
<input type="submit" value="Submit" />
</form>
<?php
}
?>
'或死亡(mysql_error()',需要是'或死(mysqli_error($ link)' - 你不能混用MySQL APIs,另外,刪除''$ subject「,」$ co中的引號mue「 – 2014-08-30 23:35:16
在打開'<?php'標記後立即在文件頂部添加錯誤報告 'error_reporting(E_ALL); ini_set('display_errors',1);'看看它是否產生任何東西。 – 2014-08-31 00:00:15
感謝您的回覆我已經做出更改,因爲您告訴我,我也添加了錯誤報告,但它不顯示任何內容,只是標準謝謝您的留言 – 2014-08-31 00:18:35