我有這種形式。基本上我想要的是根據用戶在「attn」選項列表中選擇的內容發送不同網址的自動回覆。我一直在想我可以爲每個下拉值都有一個不同的變量。然後它會將該變量傳遞給郵件腳本,該腳本將選擇要在發送的自動響應中插入哪個URL。它有時讓我頭疼。什麼是最簡單的方法來完成這一點?根據用戶的選擇清單選擇變量
我是否爲自己做更多的工作?我真的不知道,因爲我不是程序員。提前致謝!
這裏是形式:
<form name="contact_form" method="post" action="sendemail_reports.php" onsubmit="return validate_form ();">
<div id='zohoWebToLead' align=center>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="txt_body">
<table border=0 cellspacing=0 cellpadding=5 width=480 style='border-bottom-color: #999999; border-top-color: #999999; border-bottom-style: none; border-top-style: none; border-bottom-width: 1px; border-top-width: 2px; background-color:transparent;'>
<tr>
<td width='75%'><table width=480 border=0 cellpadding=5 cellspacing=0 style='border-bottom-color: #999999; border-top-color: #999999; border-bottom-style: none; border-top-style: none; border-bottom-width: 1px; border-top-width: 2px; background-color:transparent;'>
<input type="hidden" name="ip" value="'.$ipi.'" />
<input type="hidden" name="httpref" value="'.$httprefi.'" />
<input type="hidden" name="httpagent" value="'.$httpagenti.'" />
<tr></tr>
<tr>
<td colspan='2' align='left' style='border-bottom-color: #dadada; border-bottom-style: none; border-bottom-width: 2px; color:#000000; font-family:sans-serif; font-size:14px;'><strong>Send us an Email</strong></td>
</tr>
<tr>
<td nowrap style='font-family:sans-serif;font-size:12px;font-weight:bold' align='right' width='25%'> First Name : </td>
<td width='75%'><input name='visitorf' type='text' size="48" maxlength='40' /></td>
</tr>
<tr>
<td nowrap style='font-family:sans-serif;font-size:12px;font-weight:bold' align='right' width='25%'>Last Name :</td>
<td width='75%'><input name='visitorfl' type='text' size="48" maxlength='80' /></td>
</tr>
<tr>
<td nowrap style=
'font-family:sans-serif;font-size:12px;font-weight:bold' align='right' width='25%'> Email Adress : </td>
<td width='75%'><input name='visitormail' type='text' size="48" maxlength='100' /></td>
</tr>
<tr>
<td nowrap style='font-family:sans-serif;font-size:12px;font-weight:bold' align='right' width='25%'> Phone : </td>
<td width='75%'><input name='visitorphone' type='text' size="48" maxlength='30' /></td>
</tr>
<td nowrap style='font-family:sans-serif;font-size:12px;font-weight:bold' align='right' width='25%'> Subject : </td>
<td width='75%'><select name="attn" size="1">
<option value=" Investment Opportunities ">Investment Opportunities </option>
<option value=" Vacation Rentals ">Vacation Rentals </option>
<option value=" Real Estate Offerings ">Real Estate Offerings </option>
<option value=" Gatherings ">Gatherings </option>
<option value=" General ">General </option>
</select></td>
<tr>
<td nowrap style=
'font-family:sans-serif;font-size:12px;font-weight:bold' align='right' width='25%'> Message :<br />
<em>(max 5000 char)</em></td>
<td width='75%'><textarea name='notes' maxlength='5000' cols="48" rows="3"></textarea></td>
</tr>
<tr>
<td colspan=2 align=center style=''><input name='save' type='submit' class="boton" value=Send mail />
<input type='reset' name='reset' value=Reset class="boton" /></td>
</tr>
</table></td>
</tr>
</table>
</div>
</form>
這裏是郵件腳本:
<?php
//the 3 variables below were changed to use the SERVER variable
$ip = $_SERVER['REMOTE_ADDR'];
$httpref = $_SERVER['HTTP_REFERER'];
$httpagent = $_SERVER['HTTP_USER_AGENT'];
$visitorf = $_POST['visitorf'];
$visitorl = $_POST['visitorl'];
$visitormail = $_POST['visitormail'];
$visitorphone = $_POST['visitorphone'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];
//additional headers
$headers = 'From: Me <[email protected]>' . "\n" ;
$headers = 'Bcc: [email protected]' . "\n";
if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
die ("Go back! ! ");
}
if(empty($visitorf) || empty($visitormail) || empty($notes)) {
echo "<h2>Use Back - fill in all fields</h2>\n";
die ("Use back! ! ");
}
$todayis = date("l, F j, Y, g:i a") ;
$subject = "I want to download the report about $attn";
$notes = stripcslashes($notes);
$message = "$todayis [EST] \nAttention: $attn \nMessage: $notes \nFrom: $visitorf $visitorl ($visitormail) \nTelephone Number: $visitorphone \nAdditional Info : IP = $ip \nBrowser Info: $httpagent \nReferral : $httpref\n";
//check if the function even exists
if(function_exists("mail"))
{
//send the email
mail($_SESSION['email'], $subject, $message, $headers) or die("could not send email");
} else {
die("mail function not enabled");
}
header("Location: http://www.domain.com/thanks.php");
?>
是的,這是正確的,這是我想要做的。 – Kelbizzle 2010-03-22 15:52:06
然後我的代碼應該可以工作。 只需在郵件文本中使用'$ url',並且用戶將根據下拉列表中選定的值接收不同的網址。 你是否介意放棄一條線,如果這解決了你的問題? – Turbotoast 2010-03-22 16:20:46
對不起,我在別的東西旁邊。我已經做出了您所建議的更改。郵件腳本完成並在郵件中$ url不顯示相應的URL。 – Kelbizzle 2010-03-22 20:14:54