Everything posted by RadicalDude
-
Extra Fields from Contact form don't show in Email
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 : Facebook PROVINCE : British Columbia TEST 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>
- 4 replies
-
- contactform
- contact form
- php
-
Tagged with:
-
Extra Fields from Contact form don't show in Email
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>
- 4 replies
-
- contactform
- contact form
- php
-
Tagged with:
-
Extra Fields from Contact form don't show in Email
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.
- 4 replies
-
- contactform
- contact form
- php
-
Tagged with:
-
NEED HELP! Contact From PHP
Hi Guys, so I checked on what you said. noticed that I had Contact capitalized. when i made the change now i get a new error message: Internal Server ErrorThe server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log
- NEED HELP! Contact From PHP
- NEED HELP! Contact From PHP
- NEED HELP! Contact From PHP
- NEED HELP! Contact From PHP
-
NEED HELP! Contact From PHP
Action: Post here's the code I have... This is before the Document html code.... <?php // Set email variables $email_to = "my email goes here"; $email_subject = 'Contact From'; // Set required fields $required_fields = array('fullname','email','comment'); // set error messages $error_messages = array( 'fullname' => 'Please enter a Name to proceed.', 'email' => 'Please enter a valid Email Address to continue.', 'comment' => 'Please enter your Message to continue.' ); // Set form status $form_complete = FALSE; // configure validation array $validation = array(); // check form submittal if(!empty($_POST)) { // Sanitise POST array foreach($_POST as $key => $value) $_POST[$key] = remove_email_injection(trim($value)); // Loop into required fields and make sure they match our needs foreach($required_fields as $field) { // the field has been submitted? if(!array_key_exists($field, $_POST)) array_push($validation, $field); // check there is information in the field? if($_POST[$field] == '') array_push($validation, $field); // validate the email address supplied if($field == 'email') if(!validate_email_address($_POST[$field])) array_push($validation, $field); } // basic validation result if(count($validation) == 0) { // Prepare our content string $email_content = 'New Website Comment: ' . "\n\n"; // simple email content foreach($_POST as $key => $value) { if($key != 'submit') $email_content .= $key . ': ' . $value . "\n"; } // if validation passed ok then send the email mail($email_to, $email_subject, $email_content); // Update form switch $form_complete = TRUE; } } function validate_email_address($email = FALSE) { return (preg_match('/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i', $email))? TRUE : FALSE; } function remove_email_injection($field = FALSE) { return (str_ireplace(array("\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:"), '', $field)); } ?> This is in the Body: <form id="form_588312" class="appnitro" method="post" action="contact.php"> <div class="form_description"> </div> <ul > <li id="li_4" > <label class="description" for="element_4">Contact Information</label> </li> <span> <label>Full Name</label> <input id="element_4_2" name= "element_4_2" class="element text" maxlength="255" size="14" value=" <?php echo isset($_POST['fullname'])? $_POST['fullname'] : ''; ?>"/><?php if(in_array('fullname', $validation)): ?><span class="error"><?php echo $error_messages['fullname']; ?></span><?php endif; ?> </span> <p class="guidelines" id="guide_4"><small>Your Info will not be shared with anyone</small></p> <li id="li_2" > <label class="description" for="element_2">Email </label> <div> <input id="element_2" name="element_2" class="element text medium" type="text" maxlength="255" value="<?php echo isset($_POST['email'])? $_POST['email'] : ''; ?>"/><?php if(in_array('email', $validation)): ?><span class="error"><?php echo $error_messages['email']; ?></span><?php endif; ?> </div> <p class="guidelines" id="guide_2"><small>Your email address will not be shared with anyone</small></p> </li> <li id="li_3" > <label class="description" for="element_3">Email </label> <div> <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;"> <input id="element_2" name="element_2" class="element text medium" type="text" maxlength="255" value="<?php echo isset($_POST['email'])? $_POST['email'] : ''; ?>"/><?php if(in_array('email', $validation)): ?><span class="error"><?php echo $error_messages['email']; ?></span><?php endif; ?> </span> </div> <p class="guidelines" id="guide_3"><small>Your email address will not be shared with anyone</small></p> </li> <li id="li_1" > <label class="description" for="element_1">Your Message </label> <div> <textarea id="element_1" name="element_1" class="element textarea medium"><?php echo isset($_POST['comment'])? $_POST['comment'] : ''; ?></textarea><?php if(in_array('comment', $validation)): ?><span class="error"><?php echo $error_messages['comment']; ?></span><?php endif; ?> </div> <p class="guidelines" id="guide_1"><small>We will not share your contact info with anyone</small></p> </li> <label class="description" for="element_7">Where did you find us </label> <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> <option>Other</option></select> </div> <li id="li_6" > <label class="description" for="element_6">Province </label> <div> <select class="element select medium" id="element_6" name="element_6"> <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>Information written here**"</small></p> </li> <li class="buttons"> <input type="hidden" name="form_id" value="588312" /> <input id="saveForm" class="button_text" type="submit" name="Submit" value="Submit" /> <?php else: ?><p>Thank You For Your Message</p> <?php endif; ?> </li> </ul> </form><?php if($form_complete === FALSE): ?> </span></div> </div> <div class="mc0203"><div class="mc020301"></div> </div> </div> </div><!-- //END MCRIGHT --> </div><!--//END MCONTENT --> </div><!--//END CONTENT -->
- NEED HELP! Contact From PHP
- NEED HELP! Contact From PHP
-
NEED HELP! Contact From PHP
Hi Guys, I'm very new to web design. looking to put a contact form on my contact page. I've got everything together but i keep gettting a 404 error when i press the submit button. I'm wondering if it is in my Array or landing page or what..... here's the code I have... This is before the Document html code.... <?php // Set email variables $email_to = "my email goes here"; $email_subject = 'Contact From'; // Set required fields $required_fields = array('fullname','email','comment'); // set error messages $error_messages = array( 'fullname' => 'Please enter a Name to proceed.', 'email' => 'Please enter a valid Email Address to continue.', 'comment' => 'Please enter your Message to continue.' ); // Set form status $form_complete = FALSE; // configure validation array $validation = array(); // check form submittal if(!empty($_POST)) { // Sanitise POST array foreach($_POST as $key => $value) $_POST[$key] = remove_email_injection(trim($value)); // Loop into required fields and make sure they match our needs foreach($required_fields as $field) { // the field has been submitted? if(!array_key_exists($field, $_POST)) array_push($validation, $field); // check there is information in the field? if($_POST[$field] == '') array_push($validation, $field); // validate the email address supplied if($field == 'email') if(!validate_email_address($_POST[$field])) array_push($validation, $field); } // basic validation result if(count($validation) == 0) { // Prepare our content string $email_content = 'New Website Comment: ' . "\n\n"; // simple email content foreach($_POST as $key => $value) { if($key != 'submit') $email_content .= $key . ': ' . $value . "\n"; } // if validation passed ok then send the email mail($email_to, $email_subject, $email_content); // Update form switch $form_complete = TRUE; } } function validate_email_address($email = FALSE) { return (preg_match('/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i', $email))? TRUE : FALSE; } function remove_email_injection($field = FALSE) { return (str_ireplace(array("\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:"), '', $field)); } ?> This is in the Body: <form id="form_588312" class="appnitro" method="post" action="contact.php"> <div class="form_description"> </div> <ul > <li id="li_4" > <label class="description" for="element_4">Contact Information</label> </li> <span> <label>Full Name</label> <input id="element_4_2" name= "element_4_2" class="element text" maxlength="255" size="14" value=" <?php echo isset($_POST['fullname'])? $_POST['fullname'] : ''; ?>"/><?php if(in_array('fullname', $validation)): ?><span class="error"><?php echo $error_messages['fullname']; ?></span><?php endif; ?> </span> <p class="guidelines" id="guide_4"><small>Your Info will not be shared with anyone</small></p> <li id="li_2" > <label class="description" for="element_2">Email </label> <div> <input id="element_2" name="element_2" class="element text medium" type="text" maxlength="255" value="<?php echo isset($_POST['email'])? $_POST['email'] : ''; ?>"/><?php if(in_array('email', $validation)): ?><span class="error"><?php echo $error_messages['email']; ?></span><?php endif; ?> </div> <p class="guidelines" id="guide_2"><small>Your email address will not be shared with anyone</small></p> </li> <li id="li_3" > <label class="description" for="element_3">Email </label> <div> <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;"> <input id="element_2" name="element_2" class="element text medium" type="text" maxlength="255" value="<?php echo isset($_POST['email'])? $_POST['email'] : ''; ?>"/><?php if(in_array('email', $validation)): ?><span class="error"><?php echo $error_messages['email']; ?></span><?php endif; ?> </span> </div> <p class="guidelines" id="guide_3"><small>Your email address will not be shared with anyone</small></p> </li> <li id="li_1" > <label class="description" for="element_1">Your Message </label> <div> <textarea id="element_1" name="element_1" class="element textarea medium"><?php echo isset($_POST['comment'])? $_POST['comment'] : ''; ?></textarea><?php if(in_array('comment', $validation)): ?><span class="error"><?php echo $error_messages['comment']; ?></span><?php endif; ?> </div> <p class="guidelines" id="guide_1"><small>We will not share your contact info with anyone</small></p> </li> <label class="description" for="element_7">Where did you find us </label> <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> <option>Other</option></select> </div> <li id="li_6" > <label class="description" for="element_6">Province </label> <div> <select class="element select medium" id="element_6" name="element_6"> <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>Information written here**"</small></p> </li> <li class="buttons"> <input type="hidden" name="form_id" value="588312" /> <input id="saveForm" class="button_text" type="submit" name="Submit" value="Submit" /> <?php else: ?><p>Thank You For Your Message</p> <?php endif; ?> </li> </ul> </form><?php if($form_complete === FALSE): ?> </span></div> </div> <div class="mc0203"><div class="mc020301"></div> </div> </div> </div><!-- //END MCRIGHT --> </div><!--//END MCONTENT --> </div><!--//END CONTENT -->