0

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

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

1

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']);
}
Sign up to request clarification or add additional context in comments.

4 Comments

I think isset should be used instead. Correct me if I'm wrong, but doesn't an unchecked checkbox not send anything to POST/GET?
@Mike, Yes we could use isset, but empty checks for isset as well, so in this case it doesn't hurt.
Interesting. I could swear that produced a notice or warning.
@Ken - If that solves your problem, please select his answer.
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>

In your 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.       

Comments

0

just check by printing php global variable $_REQUEST on your php. You can do it by writing print_r($_REQUEST); if it does not shows anything or black array, make use of $_POST instead of $_REQUEST at each place in php file. Hope it will solve your problem.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.