dpi9530 2013-08-06 00:08
浏览 31
已采纳

PHP表单上的内爆问题

In spite of the fact that I'll probably look like a complete idiot, I'm going to post my entire files to see what I'm doing wrong.

I have form built into the page like so:

<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>

Here is the 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."
".

$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('(
+)',
'(+)',
'(\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
Email: $email
Phone: $phone
MinBedrooms: $minBedrooms
MinPrice:     
$minPrice
Move Date: $move
Realtor: $realtor
Areas: $areas", $headers );
}

echo "<script>window.location = 'thankyou.html'</script>"; 
?>

My checkboxes are not returning any values. Does anyone know why? I've worked to make things correct and I think I've got the array set up right thanks to the help of another question, but I think I'm asking the wrong question in my other post.

  • 写回答

3条回答 默认 最新

  • douxigai8757 2013-08-06 00:13
    关注

    Your $arrayValue is not defined before the first if statement which is why the is_array($arrayValue) does not succeed. Please try:

    if( !empty($_REQUEST['arrayValue'])) {
      $arrayValue = array();
      $areas = implode("," , $_REQUEST['arrayValue']);
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line