0

尽管我可能看起来像个彻头彻尾的白痴,但我还是要发布我的整个文件,看看我做错了什么。

我在页面中内置了这样的表单:

<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@email.com";

$webmaster_email2 = "email@email.com";

$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 = "test@gmail.com, ";

/* 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>"; 
?>

我的复选框没有返回任何值。有谁知道为什么?我已经努力使事情变得正确,并且我认为由于另一个问题的帮助,我已经正确设置了数组,但我认为我在另一篇文章中提出了错误的问题。

4

3 回答 3

1

$arrayValue没有在第一条if语句之前定义,这就是为什么is_array($arrayValue)不成功。请试试:

if( !empty($_REQUEST['arrayValue'])) {
  $arrayValue = array();
  $areas = implode("," , $_REQUEST['arrayValue']);
}
于 2013-08-06T00:13:45.710 回答
0

只需通过在您的 php 上打印 php 全局变量 $_REQUEST 来检查。你可以通过写 print_r($_REQUEST); 如果它没有显示任何内容或黑色数组,请在 php 文件中的每个位置使用 $_POST 而不是 $_REQUEST。希望它能解决你的问题。

于 2013-08-08T16:16:23.953 回答
0
In your HTML this should be the name:

 <input type="checkbox" name="arrayValue" id="area[4]" value="Double Diamond" style='margin-top:-5px !important;'> Double Diamond</label>

在你的 PHP

 if( !empty($_REQUEST) && is_array($arrayValue) ) 
       {

      $arrayValue = array();
      $arrayValue[] = $_REQUEST['arrayValue'];
       }
      $areas = implode(",",$arrayValue); 

 put it in the array first then implode it as a string.       
于 2013-08-06T00:15:28.383 回答