Jump to content

kdinicola

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

kdinicola's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello! Everything on this form emails the way it should except for the checkboxes. The email simply states "Array" instead of what services are checked off. I don't understand PHP that well so I used a contact form and tried to modify it to include the checkboxes. Didn't work out Please help. <?php // OPTIONS - PLEASE CONFIGURE THESE BEFORE USE! $yourEmail = "hello@mail"; // the email address you wish to receive these mails through $yourWebsite = ""; // the name of your website $thanksPage = ''; // URL to 'thanks for sending mail' page; leave empty to keep message on the same page $maxPoints = 4; // max points a person can hit before it refuses to submit - recommend 4 $requiredFields = "name,email,comments"; // names of the fields you'd like to be required as a minimum, separate each field with a comma // DO NOT EDIT BELOW HERE $error_msg = null; $result = null; $requiredFields = explode(",", $requiredFields); foreach($_POST["service"] as $value) { $service .= "$value\n"; } function clean($data) { $data = trim(stripslashes(strip_tags($data))); return $data; } function isBot() { $bots = array("Indy", "Blaiz", "Java", "libwww-perl", "Python", "OutfoxBot", "User-Agent", "PycURL", "AlphaServer", "T8Abot", "Syntryx", "WinHttp", "WebBandit", "nicebot", "Teoma", "alexa", "froogle", "inktomi", "looksmart", "URL_Spider_SQL", "Firefly", "NationalDirectory", "Ask Jeeves", "TECNOSEEK", "InfoSeek", "WebFindBot", "girafabot", "crawler", "www.galaxy.com", "Googlebot", "Scooter", "Slurp", "appie", "FAST", "WebBug", "Spade", "ZyBorg", "rabaz"); foreach ($bots as $bot) if (stripos($_SERVER['HTTP_USER_AGENT'], $bot) !== false) return true; if (empty($_SERVER['HTTP_USER_AGENT']) || $_SERVER['HTTP_USER_AGENT'] == " ") return true; return false; } if ($_SERVER['REQUEST_METHOD'] == "POST") { if (isBot() !== false) $error_msg .= "No bots please! UA reported as: ".$_SERVER['HTTP_USER_AGENT']; // lets check a few things - not enough to trigger an error on their own, but worth assigning a spam score.. // score quickly adds up therefore allowing genuine users with 'accidental' score through but cutting out real spam $points = (int)0; $badwords = array("adult", "beastial", "bestial", "blowjob", "clit", "cum", "cunilingus", "cunillingus", "cunnilingus", "cunt", "ejaculate", "fag", "felatio", "fellatio", "fuck", "fuk", "fuks", "gangbang", "gangbanged", "gangbangs", "hotsex", "hardcode", "jism", "jiz", "orgasim", "orgasims", "orgasm", "orgasms", "phonesex", "phuk", "phuq", "pussies", "pussy", "spunk", "xxx", "viagra", "phentermine", "tramadol", "adipex", "advai", "alprazolam", "ambien", "ambian", "amoxicillin", "antivert", "blackjack", "backgammon", "texas", "holdem", "poker", "carisoprodol", "ciara", "ciprofloxacin", "debt", "dating", "porn", "link=", "voyeur", "content-type", "bcc:", "cc:", "document.cookie", "onclick", "onload", "javascript"); foreach ($badwords as $word) if ( strpos(strtolower($_POST['comments']), $word) !== false || strpos(strtolower($_POST['name']), $word) !== false ) $points += 2; if (strpos($_POST['comments'], "http://") !== false || strpos($_POST['comments'], "www.") !== false) $points += 2; if (isset($_POST['nojs'])) $points += 1; if (preg_match("/(<.*>)/i", $_POST['comments'])) $points += 2; if (strlen($_POST['name']) < 3) $points += 1; if (strlen($_POST['comments']) < 15 || strlen($_POST['comments'] > 1500)) $points += 2; // end score assignments foreach($requiredFields as $field) { trim($_POST[$field]); if (!isset($_POST[$field]) || empty($_POST[$field])) $error_msg .= "Please fill in all the required fields and submit again.\r\n"; } if (!preg_match("/^[a-zA-Z-'\s]*$/", stripslashes($_POST['name']))) $error_msg .= "The name field must not contain special characters.\r\n"; if (!preg_match('/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])(([a-z0-9-])*([a-z0-9]))+' . '(\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)+$/i', strtolower($_POST['email']))) $error_msg .= "That is not a valid e-mail address.\r\n"; if (!empty($_POST['url']) && !preg_match('/^(http|https):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(\d+))?\/?/i', $_POST['url'])) $error_msg .= "Invalid website url.\r\n"; if ($error_msg == NULL && $points <= $maxPoints) { $subject = "Automatic Form Email"; $message = "You received this e-mail message through your website: \n\n"; foreach ($_POST as $key => $val) { $message .= ucwords($key) . ": " . clean($val) . "\r\n"; } $message .= "\r\n"; $message .= 'IP: '.$_SERVER['REMOTE_ADDR']."\r\n"; $message .= 'Browser: '.$_SERVER['HTTP_USER_AGENT']."\r\n"; $message .= 'Points: '.$points; if (strstr($_SERVER['SERVER_SOFTWARE'], "Win")) { $headers = "From: $yourEmail\n"; $headers .= "Reply-To: {$_POST['email']}"; } else { $headers = "From: $yourWebsite <$yourEmail>\n"; $headers .= "Reply-To: {$_POST['email']}"; } if (mail($yourEmail,$subject,$message,$headers)) { if (!empty($thanksPage)) { header("Location: $thanksPage"); exit; } else { $result = 'Thank You! Your email was successfully sent.'; $disable = true; } } else { $error_msg = 'Your mail could not be sent this time. ['.$points.']'; } } else { if (empty($error_msg)) $error_msg = 'Your mail looks too much like spam, and could not be sent this time. ['.$points.']'; } } function get_data($var) { if (isset($_POST[$var])) echo htmlspecialchars($_POST[$var]); } ?> <!DOCTYPE html> <html lang="en"> <head> <title>Contact Us</title> <meta charset="utf-8"> <link rel="stylesheet" href="css/reset.css" type="text/css" media="all"> <link rel="stylesheet" href="css/style.css" type="text/css" media="all"> <script type="text/javascript" src="js/jquery-1.4.2.min.js" ></script> <script type="text/javascript" src="js/cufon-yui.js"></script> <script type="text/javascript" src="js/Humanst521_BT_400.font.js"></script> <script type="text/javascript" src="js/Humanst521_Lt_BT_400.font.js"></script> <script type="text/javascript" src="js/cufon-replace.js"></script> <script type="text/javascript" src="js/roundabout.js"></script> <script type="text/javascript" src="js/roundabout_shapes.js"></script> <script type="text/javascript" src="js/gallery_init.js"></script> <!--[if lt IE 7]> <link rel="stylesheet" href="css/ie/ie6.css" type="text/css" media="all"> <![endif]--> <!--[if lt IE 9]> <script type="text/javascript" src="js/html5.js"></script> <script type="text/javascript" src="js/IE9.js"></script> <![endif]--> </head> <body> <!-- header --> <header> <div class="container"> <h1><a href="index.html"></a></h1> <nav> <ul> <li><a href="index.html">Home</a></li> <li><a href="aboutpg/about.html">About</a></li> <li><a href="currentpg/current.html">Current</a></li> <li><a href="contact.php" class="current">Contact</a></li> </ul> </nav> </div> </header> <!-- #gallery --> <section id="gallery"> <div class="container"> <ul id="myRoundabout"> <li><img src="images/postcard.jpg"></li> </ul> </div> </section> <!-- /#gallery --> <div class="main-box"> <div class="container"> <div class="inside"> <div class="wrapper"> <!-- aside --> <aside> <h2>Contact <span></span></h2> <!-- .contacts --> <ul class="contacts"> <li><strong>Owner:</strong></li> <li><strong>Business:</strong></li> <li><strong>Address:</strong></li> <li><strong> </strong></li> <li><strong>Phone:</strong></li> <li><strong>Email:</strong> <script type="text/javascript"> /*<![CDATA[*/ /*********************************************** * Encrypt Email script- Please keep notice intact * Tool URL: http://www.dynamicdrive.com/emailriddler/ * **********************************************/ <!-- Encrypted version of: [at] *****.*** //--> var emailriddlerarray=[83,80,87,105,110,99,55,55,64,121,97,104,111,111,46,99,111,109] var encryptedemail_id20='' //variable to contain encrypted email for (var i=0; i<emailriddlerarray.length; i++) encryptedemail_id20+=String.fromCharCode(emailriddlerarray) document.write('<a href="mailto:'+encryptedemail_id20+'"></a>') /*]]>*/ </script></li> </ul> <!-- /.contacts --> <h3>Miscellaneous info:</h3> <p><a href="http://www.fireislandferries.com" target="_blank">Fire Island Ferries</a></p> <p><a href="http://www.googlemaps.com" target="_blank">Google Maps</a></p> <p><a href="http://www.fireislandnews.net" target="_blank">Fire Island News</a></p> <p><a href="http://www.fireislandtide.net" target="_blank">Fire Island Tide</a></p> </aside> <!-- content --> <section id="content"> <article> <h2><span>*All fields are required.</span></h2> <?php if ($error_msg != NULL) { echo '<p class="error">ERROR: '. nl2br($error_msg) . "</p>"; } if ($result != NULL) { echo '<p class="success">'. $result . "</p>"; } ?> <form action="<?php echo basename(__FILE__); ?>" method="post"> <noscript> <p><input type="hidden" name="nojs" id="nojs" /></p> </noscript> <label>Services Required (check off as many as required):</label> <br> <input type="checkbox" name="service[ ]" id="service_0" value="addition" align="right">Addition<br> <input type="checkbox" name="service[ ]" id="service_1" value="remodeling">Remodeling<br> <input type="checkbox" name="service[ ]" id="service_2" value="roof">Roof<br> <input type="checkbox" name="service[ ]" id="service_3" value="foundation">Foundation<br> <input type="checkbox" name="service[ ]" id="service_4" value="kitchen">Kitchen<br> <input type="checkbox" name="service[ ]" id="service_5" value="bath">Bath(s)<br> <input type="checkbox" name="service[ ]" id="service_6" value="tile">Tile Work<br> <input type="checkbox" name="service[ ]" id="service_7" value="window">Windows<br> <input type="checkbox" name="service[ ]" id="service_8" value="deck">Deck<br> <input type="checkbox" name="service[ ]" id="service_9" value="painting">Painting<br> <input type="checkbox" name="service[ ]" id="service_10" value="power washing">Power Washing<br> <input type="checkbox" name="service[ ]" id="service_11" value="opening closing">Spring Opening/Fall Closing <br><br> <br /> <p> <small>Name: </small><input type="text" name="name" id="name" value="<?php get_data("name"); ?>" size="22" placeholder="First Last"/> <label for="name"></label> </p> <p> <small>Phone: </small><input type="text" name="email" id="email" value="<?php get_data("phone"); ?>" size="22" placeholder="(123) 123-4567"/> <label for="phone"></label> </p> <p> <small>Email: </small><input type="text" name="email" id="email" value="<?php get_data("email"); ?>" size="22" placeholder="you@email.com"/> <label for="email"></label> </p> <p> <small>Message: </small><textarea name="comments" id="comments" placeholder="Please write a brief message here."><?php get_data("comments"); ?></textarea> <label for="comments" style="display:none;"></label> </p> <p> <input name="submit" type="submit" id="submit" value="Submit Form" <?php if (isset($disable) && $disable === true) echo ' disabled="disabled"'; ?> /> </p> </form> </div> </article> </section> </div> </div> </div> </div> <script type="text/javascript"> Cufon.now(); </script> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.