Web Analytics Made Easy -
StatCounter Sendmail results do not display check box choices - CodingForum

Announcement

Collapse
No announcement yet.

Sendmail results do not display check box choices

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sendmail results do not display check box choices

    hi All, I have an simple contact us form on a web page that uses send-form-email.php

    The submission email I get is not showing the choices made using check boxes.

    Here is the test version of the form:

    Contact Info - 11th Street Victorian


    Here is the contact us form HTML code.

    Code:
    	<form method="post" id="contact-form" class="contact-info" action="send-form-email.php">
    		
    		<label>Your name:</label>
    		<input id="name" type="text" name="first_name" value="">
    
    
    		<label>Your email:</label>
    		<input id="email" type="text" name="email" value="">
    
    
    		<label>Your phone:</label>
    		<input id="phone" type="text" name="telephone" value="Optional">
    
    
    
    		<div class="who">
    			<input id="buyer" type="checkbox" value="Buyer" name="siteVisitor[]"><label name="buyer" for="buyer"><em>Buyer</em><span class="checkbox"></span></label>					
    			<input id="agent" type="checkbox" value="Agent" name="siteVisitor[]"><label name="agent" for="agent"><em>Agent</em><span class="checkbox"></span></label>					
    			<input id="neighbor" type="checkbox" value="Neighbor" name="siteVisitor[]"><label name="neighbor" for="neighbor" class="last"><em>Neighbor</em><span class="checkbox"></span></label>
    		</div>	
    
    
    		<input type="submit" class="submit" id="FormSubmit" name="submit" value="Keep me informed!">
    	</form>


    Here is the send me code:




    Code:
     
        $email_message .= "First Name: ".clean_string($first_name)."\n";
     
        $email_message .= "Email: ".clean_string($email_from)."\n";
     
        $email_message .= "Telephone: ".clean_string($telephone)."\n";
    
    $siteVisitorType  = 'None';
    if(isset($_POST['siteVisitor']) && is_array($_POST['siteVisitor']) && count($_POST['siteVisitors']) > 0){
        $siteVisitorType = implode(', ', $_POST['siteVisitor']);
    }
     
         $email_message .=  "Site Visitor: " . $siteVisitorType;


    The output in the email resulting from a submittal is the following:

    Form details below.

    First Name: uranoz
    Email: [email protected]
    Telephone: Test 092616 - v2
    Site Vistor: None



    Any help in why the check box choices are not working would be greatly appreciated.

  • #2
    var_dump($_POST['siteVisitor'])

    Then report back.
    "Tango says double quotes with a single ( ' ) quote in the middle"
    '$Name says single quotes with a double ( " ) quote in the middle'
    "Tango says double quotes ( \" ) must escape a double quote"
    '$Name single quotes ( \' ) must escape a single quote'

    Comment


    • #3
      Tangoforce,
      thanks for the suggestion. I have tried to integrate your code snippet in a number of configurations, but none have worked.

      Can you show how this snippet should be added to the send form code?

      Comment


      • #4
        To the Forum,

        I have just fixed this code. The problem was a typo in the code due to a name change: The term "siteVisitor" was plural in one instance. Changing that to singular and keeping the original code, solved the problem. Thank you for the interest and help.

        Comment


        • #5
          Originally posted by uranoz View Post
          Tangoforce,
          thanks for the suggestion. I have tried to integrate your code snippet in a number of configurations, but none have worked.
          There is nothing to configure.. you make it sound more complicated than it is. You just simply put that line of code where that variable should be valid.

          Incidentally, you have an 's' here:

          is_array($_POST['siteVisitor']) && count($_POST['siteVisitors']) > 0){
          "Tango says double quotes with a single ( ' ) quote in the middle"
          '$Name says single quotes with a double ( " ) quote in the middle'
          "Tango says double quotes ( \" ) must escape a double quote"
          '$Name single quotes ( \' ) must escape a single quote'

          Comment

          Working...
          X