June 24, 201313 yr Hello, Looking for some guidance. The contact form that I have created, I implemented new fields, but they do not show up in the email. hoping someone could help out. The LIST/Menu and the Radio buttons I have do not show up. much thanks. Edited June 24, 201313 yr by RadicalDude
June 24, 201313 yr can you post the code up so we can get to the bottom of it for you as there are several things that can cause this
June 25, 201313 yr Author Hi WDF, Also, I had to take out the Captcha validation, because the Image wouldn't show up on my page. THANK YOU FOR TAKING A LOOK AT THIS. here's the script: <?php /*********\*******************Script Configuration****************************************************/ /**********Settings*************/ $to = "yvrlabs@safe-mail.net";/**Who the email goes to**/ $email_type = "text/plain";/**Set to text/html to allow html in your email**/ $charset = "utf-8";/**Character set of email default is utf-8**/ $use_captcha = true;/**Set to true to use spam captcha image**/ $success_message = "MESSAGE SENT: Thank you for contacting us, we will get back to you as soon as possible.";/**Message to show if email was sent**/ /************************************** *End of editble section, edit below this line at your own risk **************************************/ if(!session_id())session_start();//Start session for captcha /**Handle the forms processing**/ /** *Set up form variables **/ $name = (isset($_POST['name'])) ? $_POST['name'] : false; $email = (isset($_POST['email'])) ? $_POST['email'] : false; $subject = (isset($_POST['subject'])) ? $_POST['subject'] : false; $message = (isset($_POST['message'])) ? $_POST['message'] : false; $spam_field = (isset($_POST['captcha'])) ? $_POST['captcha'] : false; $user_agent = (isset($_SERVER['HTTP_USER_AGENT'])) ? $_SERVER['HTTP_USER_AGENT'] : false; $ip_address = (isset($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : false; $find = (isset($_POST['find'])) ? $_POST['find'] : false; $province = (isset($_POST['province'])) ? $_POST['province'] : false; /**Filter vars**/ $name = stripslashes(trim(rtrim(strip_tags($name)))); $email = stripslashes(trim(rtrim(strip_tags($email)))); $subject = stripslashes(trim(rtrim(strip_tags($subject)))); $message = stripslashes(trim(rtrim(strip_tags($message)))); /************************************************************************/ $errors = array();//Errors array $success = false;//Success trigger $error_tri = false;//error trigger /***********************************************************************/ //Check if form is sent or not, if it is do validation and proccessing if(isset($_POST['send'])){ /** Check if a header injection is maybe attempted enter header iject strings you may wanna block from being used in your form to help prevent header injects **/ $inject_str = "/(cc:|bb:|from:|content\-type:)/i"; if(preg_match($inject_str,$name) || preg_match($inject_str,$email) || preg_match($inject_str,$message) ){ die('Possible header injection detected, will not send this message!'); } /**************************Enter words you wanna block from being used***************/ $black_list_array = array( "affiliate program", "viagra", "big money", "Cash back", "click this link", "claim your", "For only $", "Hair loss", "Get rich", "limited time offer", "Look younger", "Loosest slots", "Lose 10 pounds", "Lowest mortgage interest rates", "mailing list", "mailinglist", "Major credit cards", "make money", "Mlm", "Money problems", "No more debt" ); /*******Don't edit**************/ $black_list = "/(".implode("|",$black_list_array).")/i"; if(preg_match($black_list,$name) || preg_match($black_list,$email) || preg_match($black_list,$message) ){ die('You are trying to use words, that have been blacklisted, cannot send the message'); } /**************************Enter ip addresses you wanna block from sending messages***************/ $ip_list_array = array("ip1","ip2","ip3","ect..."); /*******Don't edit**************/ $ip_list = "/(".implode("|",$ip_list_array).")/i"; if(preg_match($ip_list,$ip_address)){ die('We have failed to send your message sorry!'); } /***********************************************************************/ /****************Captcha Check*******************/ /****************Name validate*******************/ if(!$name){ $errors[] = "Please enter your name!"; }else{ if(preg_match("/[^A-Za-z0-9 ]/",$name)){ $errors[] = "You may only use the letters A-Z and the numbers 0-9 in the name field!"; } } /****************Email validate*******************/ if(!$email){ $errors[] = "Please enter an email address!"; }else{ if(!filter_var($email,FILTER_VALIDATE_EMAIL)){ $errors[] = "Please enter a valid email address!"; } } /****************Subject validate*******************/ if(!$subject){ $errors[] = "Please enter a subject for contacting us!"; }else{ if(preg_match("/[^A-Za-z0-9 ]/",$subject)){ $errors[] = "You may only use the letters A-Z and the numbers 0-9 in the subject field!"; } } /****************Message Validate*******************/ if(!$message){ $errors[] = "Please enter a message!"; } /***********************Check if errors are present************************************/ if(count($errors) > 0){ $error_tri = true;//Set error trigger to true }else{ $success = true;//Set success trigger to true /************Set up headers and build message***************/ $headers = "From:$name <$to>\r\n"; $headers .= "Reply-To:$email\r\n"; $headers .= "Content-Type:$email_type;charset=$charset\r\n"; $body = ""; /**************Build message according to set email type***************/ switch( $email_type ){ case 'text/plain': $body .= " You have a new email from $name, the details of this message are below\n\n Name:$name\n\n E-mail:$email\n\n Subject:$subject\n\n User-Agent:$user_agent\n\n Ip-Address:$ip_address\n\n Message:$message "; break; case 'text/html': $body .= " You have a new email from <strong>$name</strong>, the details of this message are below<br /><br /> Name:$name<br /><br /> E-mail:$email<br /><br /> Subject:$subject<br /><br /> User-Agent:$user_agent<br /><br /> Ip-Address:$ip_address<br /><br /> Message:$message "; break; } /****************Lets send the email***********************/ if(mail($to,$subject,$body,$headers)){ // }else{ print 'Php has failed to send your message...please contact the admin of this site'; exit; } } }//End send check ?> and the Script for the FORM: <?php /********************* Display error messages or display success message insert this block of code, anywhere you would like your error message and success message to appear ********************************/ if($error_tri === true && $success === false){ print '<div class="error">'.$errors[0].'</div>'; }else if($success === true && $error_tri === false){ print '<div class="rizo_success">'.$success_message.'</div>'; } ?> <!--Set up basic html form--> <form method="post" action="Contact.php"> <div> <ul> <li> <label for="name">Name</label> <br /> <input type="text" class="rizo_input" name="name" id="name" /> </li> </ul> </div> <div> <ul> <li> <label for="email">E-mail</label> <br /> <input type="text" class="rizo_input" name="email" id="email" /> </li> </ul> </div> <div> <ul> <li> <label for="subject">Subject</label> <br /> <input type="text" class="rizo_input" name="subject" id="subject" /> </li> </ul> </div> <div> <ul> <li> <label for="message">Message</label> <br /> <textarea name="message" class="rizo_input" id="message" rows="7" cols="40"></textarea> </li> </ul> </div> <?php if($use_captcha === true){ ?> <div> <ul> <li><span class="description" style="color: rgb(15, 20, 25); font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); display: inline !important; float: none;" for="element_7"> <label class="description" for="element_7">Where did you find us </label> </span></li> </ul> <span style="color: rgb(15, 20, 25); font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); display: inline !important; float: none;"> <ul > <div> <select name="find" id="find"> <option>Where did you find us</option> <option>Google</option> <option>Facebook</option> <option>Craigslist</option> <option>A Friend</option> </select> </div> <li id="li_6" > <label class="description" for="element_6">Province </label> <div> <select class="element select medium" id="province" name="province"> <option value="" selected="selected"></option> <option value="1" >British Columbia</option> <option value="2" >Alberta</option> <option value="3" >Manitoba</option> <option value="4" >New Brunswick</option> <option value="5" >Newfoundland/labrador</option> <option value="6" >Northwest Territories</option> <option value="7" >Nova Scotia</option> <option value="8" >Nunavut</option> <option value="9" >Ontario</option> <option value="10" >Prince Edward Island</option> <option value="11" >Quebec</option> <option value="12" >Saskatchewan</option> <option value="13" >Yukon</option> </select> </div> </li> <li id="li_5" > <label class="description" for="element_5">I declare the statement to be true </label> <span> <input id="element_5_1" name="element_5_1" class="element checkbox" type="checkbox" value="1" /> <label class="choice" for="element_5_1">Yes</label> <input id="element_5_2" name="element_5_2" class="element checkbox" type="checkbox" value="1" /> <label class="choice" for="element_5_2">No</label> </span> <p class="guidelines" id="guide_5"><small>PARAGRAPH GOES HERE</small></p> </li> </ul> </span><br /> <br /> </div> <?php } ?> <div><input type="submit" name="send" value="Send" /></div> </form>
June 25, 201313 yr Hi there RD, look at this bit here : $name = (isset($_POST['name'])) ? $_POST['name'] : false; $email = (isset($_POST['email'])) ? $_POST['email'] : false; $subject = (isset($_POST['subject'])) ? $_POST['subject'] : false; $message = (isset($_POST['message'])) ? $_POST['message'] : false; $spam_field = (isset($_POST['captcha'])) ? $_POST['captcha'] : false; $user_agent = (isset($_SERVER['HTTP_USER_AGENT'])) ? $_SERVER['HTTP_USER_AGENT'] : false; $ip_address = (isset($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : false; $find = (isset($_POST['find'])) ? $_POST['find'] : false; $province = (isset($_POST['province'])) ? $_POST['province'] : false; from what I can see, you are not appending the extra information to the message. try something like this : $name = (isset($_POST['name'])) ? $_POST['name'] : false; $email = (isset($_POST['email'])) ? $_POST['email'] : false; $subject = (isset($_POST['subject'])) ? $_POST['subject'] : false; $message = (isset($_POST['message'])) ? $_POST['message'] : false; $spam_field = (isset($_POST['captcha'])) ? $_POST['captcha'] : false; $user_agent = (isset($_SERVER['HTTP_USER_AGENT'])) ? $_SERVER['HTTP_USER_AGENT'] : false; $ip_address = (isset($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : false; $find = (isset($_POST['find'])) ? $_POST['find'] : false; $province = (isset($_POST['province'])) ? $_POST['province'] : false; // APPENDING ADITIONAL INFORMATION TO THE MESSAGE $message = 'REFERAL SOURCE : '.($find?$find:'none selected').PHP_EOL.PHP_EOL. 'PROVINCE : '.($province?$province:'none selected').PHP_EOL.PHP_EOL. $message; you need to give the select options values : <select name="find" id="find"> <option>Where did you find us</option> <option value="Google">Google</option> <option value="Facebook">Facebook</option> <option value="Craigslist">Craigslist</option> <option value="A Friend">A Friend</option> </select> Note that you will get the set value of the inputs in the province checkboxes e.g British Columbia will send the number 1 perhaps change there values to the text you would like sent. Hope this all helps a little
June 25, 201313 yr Author WDF, You're AWESOME! the message comes through. How can i get the referal source to show up down from the message: Message:REFERAL SOURCE : FacebookPROVINCE : British ColumbiaTEST TEST Also, how do i get the radio button to show? radio button: <label class="description" for="element_5">I declare the statement to be true </label> <span> <input id="element_5_1" name="element_5_1" class="element checkbox" type="checkbox" value="1" /> <label class="choice" for="element_5_1">Yes</label> <input id="element_5_2" name="element_5_2" class="element checkbox" type="checkbox" value="1" /> <label class="choice" for="element_5_2">No</label> Edited June 25, 201313 yr by RadicalDude
Create an account or sign in to comment