jonnyroboto Posted April 22, 2009 Share Posted April 22, 2009 I have a form that submits it's info to my email. When people check the ckeckboxes on my form, and submit, the info comes back to me as "array". I want to be able to see what it is they checked on so I can gather the proper info for when I call them back. Anyone know what I'm doing wrong? Form Code: <?php echo ' <body bgcolor="#9999cc"> <form action="processContact.php" method="post"> <font face="Arial, Helvetica, sans-serif"> <h1 align="center"><font size="5" color="#FFFFFF">Contact Us</font></h1> <div align="center"> <font size="2"><strong> <font color="#FFFFFF"> Name:</font></strong> <input type="text" name="name" size="30" /> </font> <br /> <br /> <font size="2"><font color="#FFFFFF"><strong>* Email:</strong></font> <input type="text" name="email" size="30" /> </div> <br /> <div align="center"> <font color="#FFFFFF"> <strong>Overall Rating of the site:</strong><br/> [<input checked="checked" name="rating" type="radio" value="good" />Good] [<input name="rating" type="radio" value="bad" />Fair] [<input name="rating" type="radio" value="ugly" />Bad]</font> <br /> <br /> <table> <tr> <td> <p align="left"><font color="#FFFFFF" size="2"><strong>* What can we help you with?</strong><br /> <input type="checkbox" name="box[]" value="Hotel Information and Reservations" />Hotel Information and Reservations<br /> <input type="checkbox" name="box[]" value="Vacation Home Information and Reservations" />Vacation Home Information and Reservations<br /> <input type="checkbox" name="box[]" value="Vacation Packages and Tickets" />Vacation Packages and Tickets<br /> <input type="checkbox" name="box[]" value="Affiliate Program Information" />Affiliate Program<br /> <input type="checkbox" name="box[]" value="Other Information" />Other </font> <font color="#FFFFFF"><input type="text" name="other" size="20" /></font></p> </td> </tr> </table> <font color="#FFFFFF"> <br /> <font size="1"><i>* Required Fields</i></font> <br /> <h2 align="center"><font color="#FFFFFF">Comments</font></h2> <div align="center"> <font face="Arial, Helvetica, sans-serif"><textarea name="feedback" rows="6" cols="30"></textarea></font> </div> <hr /> '; ?> <?php require_once('recaptchalib.php'); $publickey = "..."; // you got this from the signup page echo recaptcha_get_html($publickey); ?> <?php echo ' <br /><input type="submit" /> </form></body> '; ?> Processing Code: <?php require_once('recaptchalib.php'); $privatekey = "..."; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { die ("The reCAPTCHA wasn’t entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); } /* Subject and Email Variables */ $emailSubject = 'Contact Form'; $webMaster = '...'; /* Gathering Data Variables */ $emailField = $_POST['email']; $nameField = $_POST['name']; $ratingField = $_POST['rating']; $box = $_POST['box']; $otherField = $_POST['other']; $feedbackField = $_POST['feedback']; $body = <<<EOD <br><hr><br> Email: $email <br> Name: $name <br> Site Rating: $rating <br> Info Needed: $box <br> Other Attraction Detail: $other <br> Comments: $feedback <br> EOD; $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); /* Results Rendered HTML */ $theResults = <<<EOD <html> <head> <title>Thank you!</title> <style type="text/css"> h1 { color: #ffffff; text-align: center; } h2 { color: #ffffff; text-align: center; } h3 { color: #ffffff; text-align: center; } a:link { color: #330033; text-decoration: none; } a:visited { color: #000033; text-decoration: none; } a:hover { color: #663399; text-decoration: none; } </style> </head> <body bgcolor="#9999cc"> <form> <h1>Thank you.</h1><br> <h2>An email has been sent to us and we will be contacting you soon.</h2> <h3>Thank you again for visiting wdwvip.com You may click below to close this window.</h3> <div align="center"> <input type="button" value="Close Window" onClick="window.close()"></div> </form> <div align="center"> <a href="javascript:window.close()">Close Window</a> </div> </body> </html> EOD; echo "$theResults"; ?> Link to comment https://forums.phpfreaks.com/topic/155236-array-info-in-my-contact-form-email-not-working/ Share on other sites More sharing options...
phpfreakjav Posted April 22, 2009 Share Posted April 22, 2009 yes the name box[] in your html should be changed to box. Link to comment https://forums.phpfreaks.com/topic/155236-array-info-in-my-contact-form-email-not-working/#findComment-816708 Share on other sites More sharing options...
jonnyroboto Posted April 22, 2009 Author Share Posted April 22, 2009 thank you for replying. When I submit the form after checking all the boxes, it only shows the last one submitted. If my guest check all the boxes, is there a way to show all of them in my emial? Link to comment https://forums.phpfreaks.com/topic/155236-array-info-in-my-contact-form-email-not-working/#findComment-816713 Share on other sites More sharing options...
phpfreakjav Posted May 2, 2009 Share Posted May 2, 2009 yes you have to give a different name to each box in ur html and then use x=_POST['box1']; z2=_POST['box2']; i hope u understand what I am trying to say. Link to comment https://forums.phpfreaks.com/topic/155236-array-info-in-my-contact-form-email-not-working/#findComment-824509 Share on other sites More sharing options...
Ken2k7 Posted May 2, 2009 Share Posted May 2, 2009 No, change the name back to "box[]". Then when you did: $box = $_POST['box']; You would want to make a loop because it comes back with an array of all selected checkboxes. So something like: $boxes = $_POST['box']; $values = ''; foreach ($boxes as $box => $value) { $values .= $value . ', '; } Then use $values instead of $boxes. Link to comment https://forums.phpfreaks.com/topic/155236-array-info-in-my-contact-form-email-not-working/#findComment-824515 Share on other sites More sharing options...
phpfreakjav Posted June 1, 2009 Share Posted June 1, 2009 Yes, that is very smart. If you have a lot of text boxes. Link to comment https://forums.phpfreaks.com/topic/155236-array-info-in-my-contact-form-email-not-working/#findComment-846695 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.