儘管我可能看起來像一個完全白癡的事實,但我會發布我的整個文件,看看我做錯了什麼。Implode問題在PHP表格
我有形式內置在頁面像這樣:
<form method="post" class="form-horizontal" id="final_form" action="send_mail.php">
<h2>Search for your dream home<br />
and save now!</h2>
<legend>Which Areas are you interested in?</legend>
<div class="areas row-fluid" style="text-align:left !important;">
<div class='span5' style='margin-left:0px !important;'>
<label>
<input type="checkbox" name="arrayValue[]" id="area[0]" value="Sparks" style='margin-top:-5px !important;'> Sparks</label>
</div>
<div class='span5' style='margin-left:0px !important;'>
<label >
<input type="checkbox" name="arrayValue[]" id="area[1]" value="Stead" style='margin-top:-5px !important;'> Stead</label>
</div>
<div class='span5' style='margin-left:0px !important;'>
<label>
<input type="checkbox" name="arrayValue[]" id="area[2]" value="North Reno" style='margin-top:-5px !important;'> North Reno</label>
</div>
<div class='span5' style='margin-left:0px !important;'>
<label >
<input type="checkbox" name="arrayValue[]" id="area[3]" value="South Reno" style='margin-top:-5px !important;'> South Reno</label>
</div>
<div class='span5' style='margin-left:0px !important;'>
<label >
<input type="checkbox" name="arrayValue[]" id="area[4]" value="Double Diamond" style='margin-top:-5px !important;'> Double Diamond</label>
</div>
</div>
<input type="button" onclick="jQuery('#myModal').modal('show')" value="CONTINUE" />
</div>
</div>
</div>
<!--banner area end-->
<!--content area 1 start-->
<div id="content1">
<div class="content1_in"> <span>
<h2 style="line-height:40px;font-size:40px;padding-bottom:10px">Some Content</h2>
<p style="line-height:30px;font-size:22px;text-align: left">Some Content!</p>
</span>
<div class="img">
<img src="image" alt="" />
</div>
</div>
</div>
<!--content area 1 end-->
<!--content area 1 start-->
<div id="content2">
<div class="content2_in"> <span>
</span>
<div class="img">
<img src="http://f14.co/realtor/assets/images/ipad-img.png" alt="" />
<div class="key"></div>
</div>
</div>
</div>
<!--content area 1 end-->
<!--content area 3 start-->
<div id="content3">
<div class="content3_in">
<div class="img">
<img src="image" alt=""
/>
</div>
<div class="free"></div>
</div>
</div>
<!--content area 3 end-->
<div id="footer">
<div class="footer_in">
This Website Is Brought To You By: Ken Holden</div>
</div>
<!-- Modal -->
<div id="myModal" class="modal hide fade modal-survey" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
<h3 id="myModalLabel" class="survey_title">What type of home are you looking for?</h3>
</div>
<input type="hidden" name="template" id="template" value="Buyers" />
<div class="modal-body">
<div id="lead_info_1">
<div class="input select">
<div class=""></div>
<div class="span-4 step-2-dropdown append-bottom control-group">
<select class="span3 required" name="minPrice" id="minPrice">
<option value="">Price</option>
<option value='$50,000 - $150000'>$50,000 - $150000</option><option value='$150,000 -
$300,000'>$150,000 - $300,000</option><option value='$300,000 - $400,000'>
$300,000 - $400,000</option><option value='$400,000 +'>$400,000 +</option>
</select>
</div>
</div>
<div class="input select">
<div class=""></div>
<div class="span-4 step-2-dropdown append-bottom control-group">
<select class="span3 required" name="minBedrooms" id="minBedrooms">
<option value="">Bedrooms</option>
<option value='1-2'>1-2</option><option value='2-4'>2-4</option><option value='4+'>4+
</option> </select>
</div>
</div>
<div class="input select">
<div class=""></div>
<div class="span-4 step-2-dropdown append-bottom control-group">
<select class="span3 required" name="minBathrooms" id="minBathrooms">
<option value="">Bathrooms</option>
<option value='1-2'>1-2</option><option value='2-4'>2-4</option><option value='4+'>4+
</option> </select>
</div>
</div>
<div class="input select">
<div class=""></div>
<div class="span-8 step-2-dropdown2 append-bottom control-group">
<select class="span3 required" name="realtor" id="realtor">
<option value="">Currently Working With a Realtor</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</div>
</div>
<div class="input select">
<div class=""></div>
<div class="span-8 step-2-dropdown2 append-bottom control-group">
<select class="span3 required" name="move" id="move">
<option value="">When Do You Plan On Moving?</option>
<option value="30-90 days">30-90 days</option>
<option value="90-120 days">90-120 days</option>
<option value="I'm just looking">I'm just looking</option>
</select>
</div>
</div>
<!--<img src="http://localcommissionsystem.com/assets/app/images/SearchDealsLikeThis.png" />-->
</div>
<div id="lead_info_2" style="display:none">
<center>
</center>
</div>
<div id="lead_info_3" style="display:none">
<textarea class="" id="wantedArea" name="wantedArea" style="display:none;"></textarea>
<div class="control-group">
<label class="control-label" for="fname">First Name</label>
<div class="controls">
<input class="required" type="text" id="fname" name="fname" placeholder="First Name" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="email">Email</label>
<div class="controls">
<input class="required" type="text" id="email" name="email" placeholder="Valid Email Required" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="phone">Cell Phone</label>
<div class="controls">
<input class="required" type="text" id="phone" name="phone" placeholder="Cell Phone" />
</div>
</div>
</div>
</div>
這裏是PHP
<?php
$webmaster_email = "[email protected]";
$webmaster_email2 = "[email protected]";
$fname = $_REQUEST['fname'];
$email = $_REQUEST['email'];
$phone = $_REQUEST['phone'];
$minBedrooms = $_REQUEST['minBedrooms'];
$minBathrooms = $_REQUEST['minBathrooms'];
$minPrice = $_REQUEST['minPrice'];
$move = $_REQUEST['move'];
$realtor = $_REQUEST['realtor'];
if(!empty($_REQUEST) && is_array($arrayValue)) {
$arrayValue = array();
$areas = implode("," , $_REQUEST['arrayValue']);
}
$emailfrom = $_REQUEST['email'];
$headers = 'From: '.$emailfrom."\r\n".
$email_to = "[email protected], ";
/* This bit sets the URLs of the supporting pages.
If you change the names of any of the pages, you will need to change the values here.
*/
$feedback_page = "index.html";
$thankyou_page = "thankyou.html";
/*
The following function checks for email injection.
Specifically, it checks for carriage returns - typically used by spammers to inject a CC
list.
*/
function isInjected($str) {
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str)) {
return true;
}
else {
return false;
}
}
// If the user tries to access this script directly, redirect them to the feedback
form,
if (!isset($_REQUEST['email'])) {
header("Location: $feedback_page");
}
// If email injection is detected, redirect to the error page.
elseif (isInjected($email)) {
header("Location: $error_page");
}
// If we passed all previous tests, send the email then redirect to the thank you page.
else {
mail($email_to, "You Have a New Lead",
"Name: $fname\nEmail: $email\nPhone: $phone\nMinBedrooms: $minBedrooms\nMinPrice:
$minPrice\nMove Date: $move\nRealtor: $realtor\nAreas: $areas", $headers);
}
echo "<script>window.location = 'thankyou.html'</script>";
?>
我複選框不返回任何值。有誰知道爲什麼?我一直在努力使事情正確,並且我想我已經通過另一個問題的幫助來設置陣列,但我想我在我的其他帖子中提出了錯誤的問題。
我認爲'isset'應該用來代替。糾正我,如果我錯了,但不是一個未經檢查的複選框不發送任何東西POST/GET? – Mike
@Mike,是的,我們可以使用'isset',但'empty'也檢查'isset',所以在這種情況下它不會受到傷害。 – vee
就是這樣!你是先生,是那個男人。 – Ken