我重建這個給你。沒有測試,但應該工作。下面的PHP將處理電子郵件發送,而不是直接從表單中。基本上,html表單將收集數據,並將其發送回此頁面,電子郵件將發送至您選擇的電子郵件,併發送您選擇的商店名稱。
我認爲這是你想要的..讓我知道你是否想要做任何改變,如果它的工作。
<?php
mysql_connect("YOUR HOST ADDRESS","YOUR USERNAME","YOUR PASSWORD");
mysql_select_db("YOUR DB NAME");
////////////////////////////////////////////////////////////////////
// // COLLECT FORM INFO AND SEND EMAIL // //
///////////////////////////////////////////////////////////////////
if (isset ($_POST['email'])){
$email = $_POST['email'];
$store = $_POST['store'];
$subject = ''; // Set the subject text here
$message = $store; // The store you selected
$to = $email; // The email you selected
$type = 'HTML'; // Ignore this
$charset = 'utf-8'; // Ignore this
$mail = 'Store Info'; // From Address
$uniqid = md5(uniqid(time())); // Ignore this
$headers = 'From: '.$mail."\n"; // Ignore this
mail($to, $subject, $message, $headers); // Your mail being sent!
print 'Success! You have sent '.$store.' to '.$email.'!'; // Your success msg! Set this to anything. A lot of options here.
exit();
}
////////////////////////////////////////////////////////////////////
// // GET DATA FROM SQL DB // //
///////////////////////////////////////////////////////////////////
$genManSelector = ''; //Initialize dynamic dropdown selection list variable for email list
$storeSelector = ''; //Initialize dynamic dropdown selection list variable for store list
$sql = mysql_query("SELECT GenManageEmail, Store FROM storeconst ORDER BY Store ASC");
while($row = mysql_fetch_array($sql)){
$GenManageEmail = $row["GenManageEmail"];
$getStore = $row["Store"];
$genManSelector .= '<option value="'.$GenManageEmail.'">'.$GenManageEmail.'</option>';
$storeSelector .= '<option value="'.$getStore.'">'.$getStore.'</option>';
//Adove is your dynamic dropdown selection lists. All stores and
//emails that are in your database will be available for selection.
}
?>
下面的HTML表單,將表單動作設置爲你的頁面url。
<form action="thisPage.php" method="post">
Select Email:<br>
<select name="email">
<?php print $storeSelector ?>
</select><br>
Select Store:<br>
<select name="store">
<?php print $storeSelector ?>
</select><br>
<input type="submit" value="Send to Manager">
</form>
這是很基本的和真的應該打扮
嗯,沒有。要動態更改客戶端上的內容,您需要一些JavaScript - 您不能在PHP中執行此操作,因爲您生成的HTML是在服務器端創建的。 – andrewsi