Jump to content

deziner76hd

Members
  • Posts

    25
  • Joined

  • Last visited

Everything posted by deziner76hd

  1. And with the above commented out i still get this printed on the page Index: 0 - Value: first Index: 1 - Value: second Index: 2 - Value: third Warning: Cannot modify header information - headers already sent by (output started at /home/richardi/public_html/test2.php:33) in /home/richardi/public_html/test2.php on line 93
  2. Ok I commented out: if( $_POST['submitted'] == 'yes') { echo '<pre>'; print_r($_POST); echo '</pre><br>'; And All I can get it to print to email is: Array Why?
  3. Well I am trying to learn and understand all this. I start to think I have things under control and when I try what I think will work (several variations) and it doesn't it's gets a little frustrating. This is what is returned A user Gary T White submitted the contact form: (working) Full Name: Gary T White (working) Email: test@tesitnmf.com (working) Gender: female (working) Languages I Speak: English (not working) Preferred Language: English (working) Favorite color: Array (not working) Education: HighSchool (working) Check Boxes: Array (not working) Q1: the ands Message: xcghnfcg IP: 74.74.118.219 Above Head <?php $your_email ='gwhite@dezinezone2002.com';// <<=== update to your email address session_start(); $errors = ''; $name = ''; $visitor_email = ''; $user_message = ''; if(isset($_POST['submit'])) { $name = $_POST['name']; $visitor_email = $_POST['email']; $visitor_q1 = $_POST['q1']; $user_message = $_POST['message']; $gender = $_POST['gender']; $language = $_POST['lang']; $Preferred = $_POST['preflang']; $color = $_POST['color']; $education = $_POST['education']; $boxes = $_POST['boxes']; ///------------checkbox------------- if( $_POST['submitted'] == 'yes') { echo '<pre>'; print_r($_POST); echo '</pre><br>'; if( is_array($_POST['boxes']) ) { foreach( $_POST['boxes'] as $key => $value ) { echo "Index: $key - Value: $value<br>"; } } } ///// collecting form data color ///// @$color= $_POST['color']; if( is_array($color)){ while (list ($key, $val) = each ($color)) { ////---echo "$val <br>"; } }//else{echo "not array";} ///------------Do Validations------------- if(empty($name)||empty($visitor_email)) { $errors .= "\n Name and Email are required fields. "; } if(IsInjected($visitor_email)) { $errors .= "\n Bad email value!"; } if(empty($_SESSION['6_letters_code'] ) || strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0) { //Note: the captcha code is compared case insensitively. //if you want case sensitive match, update the check above to // strcmp() $errors .= "\n The captcha code does not match!"; } if(empty($errors)) { //send the email $to = $your_email; $subject="New form submission"; $from = $your_email; $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $body = "A user $name submitted the contact form:\n". "Full Name: $name\n". "Email: $visitor_email \n". "Gender: $gender \n". "Languages I Speak: $lang \n". "Preferred Language: $preflang \n". "Favorite color: $color \n". "Education: $education \n". "Check Boxes: $boxes \n". "Q1: $visitor_q1 \n". "Message: \n ". "$user_message\n". "IP: $ip\n"; $headers = "From: $from \r\n"; $headers .= "Reply-To: $visitor_email \r\n"; mail($to, $subject, $body,$headers); header('Location: thank-you.html'); } } // Function to validate against any email injection attempts function IsInjected($str) { $injections = array('(\n+)', '(\r+)', '(\t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } } ?> Form <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="POST" name="contact_form" class="style25"> <p> <label for='name'>Full Name: </label><br> <input type="text" name="name" value='<?php echo htmlentities($name) ?>'> </p> <p> <label for='email'>Email: </label><br> <input type="text" name="email" value='<?php echo htmlentities($visitor_email) ?>'> <p> <p> <label for='q1'>Q1: </label><br> <input type="text" name="q1" value='<?php echo htmlentities($visitor_q1) ?>'> <p>My gender is: <p> <input type="radio" name="gender" value="male" <?php echo $_POST['gender'] == 'male' ? 'selected="selected"' : ''; ?>/> <label for='gender'>Male: </label> <br /> <input type="radio" name="gender" value="female" <?php echo $_POST['gender'] == 'female' ? 'selected="selected"' : ''; ?>/> <label for='Gender'>Female:</label> <br /><br /> <label for='boxes'>Checkboxes:</label><br /><br /> First: <input type="checkbox" name="boxes[]" value="first" <?php echo (is_array($_POST['boxes']) && in_array('first', $_POST['boxes'])) ? 'checked = "checked"' : ''; ?>><br> Second: <input type="checkbox" name="boxes[]" value="second" <?php echo (is_array($_POST['boxes']) && in_array('second', $_POST['boxes'])) ? 'checked = "checked"' : ''; ?>><br> Third: <input type="checkbox" name="boxes[]" value="third" <?php echo (is_array($_POST['boxes']) && in_array('third', $_POST['boxes'])) ? 'checked = "checked"' : ''; ?>><br> <br /><br />Select a Level of Education:<br /><br /> <select name="education"> <option value="Jr.High">Jr.High</option> <option value="HighSchool">HighSchool</option> <option value="College">College</option></select>:<br /><br /> Select your favorite time of day::<br /><br /> <select name="TofD" size="3"> <option value="Morning">Morning</option> <option value="Day">Day</option> <option value="Night">Night</option></select>:<br /><br /> Select your favorite color::<br /><br /> <select name='color[]' size=4 multiple> <option value='blue'>Blue</option> <option value='green'>Green</option> <option value='red'>Red</option> <option value='yellow'>Yelllow</option> <option value='' selected>Select a Color </option> <option value='white'>White</option> </select> <p>I speak the following languages: </p> <p> <input type="checkbox" name="lang" value="English" <?php echo $_POST['lang'] == 'en' ? 'selected="selected"' : ''; ?>/> English<br /> <input type="checkbox" name="lang" value="Français" <?php echo $_POST['lang'] == 'fr' ? 'selected="selected"' : ''; ?>/> Français<br /> <input type="checkbox" name="lang" value="Español" <?php echo $_POST['lang'] == 'es' ? 'selected="selected"' : ''; ?>/> Español<br /> </p> <p>My preferred language is: </p> <input type="radio" name="preflang" value="English" <?php echo $_POST['preflang'] == 'en' ? 'selected="selected"' : ''; ?>/> <label for='Preferred'>English: </label> <br /> <input type="radio" name="preflang" value="Français" <?php echo $_POST['preflang'] == 'fr' ? 'selected="selected"' : ''; ?>/> <label for='Preferred'>Français:</label> <br /> <input type="radio" name="preflang" value="Español" <?php echo $_POST['preflang'] == 'es' ? 'selected="selected"' : ''; ?>/> <label for='Preferred'>Español:</label> <p> <label for='message'>Message:</label> <br> <textarea name="message" rows=8 cols=30><?php echo htmlentities($user_message) ?></textarea> </p> <p> <img src="captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg' ><br> <label for='message'>Enter the code above here :</label><br> <input id="6_letters_code" name="6_letters_code" type="text"><br> <small>Can't read the image? click <a href='javascript: refreshCaptcha();'>here</a> to refresh</small></p> <input type="submit" value="Submit" name='submit'> </form>
  4. Ok I see how this all works but I still can't get it to print to e-mail
  5. Yes The last explanation of how it is all put together actually clicked and gave me insight into how it all works. Now I will try to implement it into my existing form and get it to work. Thank you
  6. Did you notice it's 1:00am again? it seems like I am always up at 1:00 am working on something. I want you to know I really do appreciate all the time you have put in helping me.
  7. If I include it in a form and print to email it sends a return of Array A user gary submitted the contact form: Full Name: gary Email: gwhite@dezinezone2002.com Gender: male Languages I Speak: English Preferred Language: en All Boxex: Array Q1: an answer Message: ukg IP: 74.74.118.219
  8. Thank you can you tell me why it prints this above the answers it prints? Array ( [boxes] => Array ( [0] => first [1] => second ) [submitted] => yes [submit] => Submit ) This is what it prints in entirety. Array ( [boxes] => Array ( [0] => first [1] => second [2] => third ) [submitted] => yes [submit] => Submit ) Index: 0 - Value: first Index: 1 - Value: second Index: 2 - Value: third First: Second: Third: I would think it should just print this with all three checked Index: 0 - Value: first Index: 1 - Value: second Index: 2 - Value: third
  9. Am I headed in the correct direction? <?php echo $_POST[$lang[]] = "English" ? 'selected="selected"' : ''; ?>/ $lang[] = "Français"; $lang[] = "Español";
  10. Ok Here is my array $lang[] = "English"; $lang[] = "Français"; $lang[] = "Español";
  11. I am not familiar with how I would write an array. Could you show me what I need to do or point me in the direction of a good tutorial?
  12. Ok When I choose all 3 English French and Spanish it only returns Spanish I t only returns the last one I choose. Can anyone see where I am missing something to make it choose all the check boxes and print them? Thank you for your help Result A user gary submitted the contact form: Full Name: gary Email: gwhite@dezinezone2002.com Gender: male Language: es Q1: an answer Message: fdsd IP: 74.74.118.219 Above header <?php $your_email ='gwhite@dezinezone2002.com';// <<=== update to your email address session_start(); $errors = ''; $name = ''; $visitor_email = ''; $user_message = ''; if(isset($_POST['submit'])) { $name = $_POST['name']; $visitor_email = $_POST['email']; $visitor_q1 = $_POST['q1']; $user_message = $_POST['message']; $gender = $_POST['gender']; $language = $_POST['lang']; ///------------Do Validations------------- if(empty($name)||empty($visitor_email)) { $errors .= "\n Name and Email are required fields. "; } if(IsInjected($visitor_email)) { $errors .= "\n Bad email value!"; } if(empty($_SESSION['6_letters_code'] ) || strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0) { //Note: the captcha code is compared case insensitively. //if you want case sensitive match, update the check above to // strcmp() $errors .= "\n The captcha code does not match!"; } if(empty($errors)) { //send the email $to = $your_email; $subject="New form submission"; $from = $your_email; $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $body = "A user $name submitted the contact form:\n". "Full Name: $name\n". "Email: $visitor_email \n". "Gender: $gender \n". "Language: $lang \n". "Q1: $visitor_q1 \n". "Message: \n ". "$user_message\n". "IP: $ip\n"; $headers = "From: $from \r\n"; $headers .= "Reply-To: $visitor_email \r\n"; mail($to, $subject, $body,$headers); header('Location: thank-you.html'); } } // Function to validate against any email injection attempts function IsInjected($str) { $injections = array('(\n+)', '(\r+)', '(\t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } } ?> In form <p>I speak the following languages: </p> <p> <input type="checkbox" name="lang" value="en" <?php echo $_POST['lang'] == 'en' ? 'selected="selected"' : ''; ?>/> English<br /> <input type="checkbox" name="lang" value="fr" <?php echo $_POST['lang'] == 'fr' ? 'selected="selected"' : ''; ?>/> Français<br /> <input type="checkbox" name="lang" value="es" <?php echo $_POST['lang'] == 'es' ? 'selected="selected"' : ''; ?>/> Español<br /> </p>
  13. Radio buttons work great! I'm starting to understand somewhat how this works. I have a 100 hours in something that should take a couple but hopefully I will retain the basic concepts. I tried to incorporate the same code into check boxes but it didn't work. Should it work and I just have something small wrong in the syntax or is it an entirely different type of code I should be using for check boxes? Above head <?php $your_email ='gwhite@dezinezone2002.com';// <<=== update to your email address session_start(); $errors = ''; $name = ''; $visitor_email = ''; $user_message = ''; if(isset($_POST['submit'])) { $name = $_POST['name']; $visitor_email = $_POST['email']; $visitor_q1 = $_POST['q1']; $user_message = $_POST['message']; $gender = $_POST['gender']; $language = $_POST['lang']; ///------------Do Validations------------- if(empty($name)||empty($visitor_email)) { $errors .= "\n Name and Email are required fields. "; } if(IsInjected($visitor_email)) { $errors .= "\n Bad email value!"; } if(empty($_SESSION['6_letters_code'] ) || strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0) { //Note: the captcha code is compared case insensitively. //if you want case sensitive match, update the check above to // strcmp() $errors .= "\n The captcha code does not match!"; } if(empty($errors)) { //send the email $to = $your_email; $subject="New form submission"; $from = $your_email; $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $body = "A user $name submitted the contact form:\n". "Full Name: $name\n". "Email: $visitor_email \n". "Gender: $gender \n". "Language: $lang \n". "Q1: $visitor_q1 \n". "Message: \n ". "$user_message\n". "IP: $ip\n"; $headers = "From: $from \r\n"; $headers .= "Reply-To: $visitor_email \r\n"; mail($to, $subject, $body,$headers); header('Location: thank-you.html'); } } // Function to validate against any email injection attempts function IsInjected($str) { $injections = array('(\n+)', '(\r+)', '(\t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } } ?> In Form <p> <input type="checkbox" name="language" value="en" <?php echo $_POST['lang'] == 'en' ? 'selected="selected"' : ''; ?>/> English<br /> <input type="checkbox" name="language" value="fr" <?php echo $_POST['lang'] == 'fr' ? 'selected="selected"' : ''; ?>/> Français<br /> <input type="checkbox" name="language" value="es" <?php echo $_POST['lang'] == 'es' ? 'selected="selected"' : ''; ?>/> Español<br /> </p>
  14. It Works! I had a capital G instead of lower case in name="gender" <input type="radio" name="gender" value="female" <?php echo $_POST['gender'] == 'female' ? I need to set up the check boxes. Will they get set up the same as the radio buttons except with different values? You can't imagine how much I appreciate all your help. This also gives me some insight on how php works.
  15. I tried that previously and it still didn't work. I just changed it back again and I still can't get it to print to e-mail Thank you for all the help you have given me so far. I really do appreciate it. Here is the test form I am using http://www.richardiv.com/test2.php A user SMS ME submitted the contact form: Full Name: SMS ME Email: test@testing.com Gender: Language: Q1: an answer Message: gn IP: 74.74.118.219
  16. Ok I still can't get this to print to the e-mail correctly. Could you please take a look at my code again to see what I am missing? Thank you Result in email A user SMS ME submitted the contact form: Full Name: SMS ME Email: gwhite@dezinezone2002.com Gender: Language: Q1: an answer Message: mn,b IP: 74.74.118.219 Code above header <?php $your_email ='gwhite@dezinezone2002.com';// <<=== update to your email address session_start(); $errors = ''; $name = ''; $visitor_email = ''; $user_message = ''; if(isset($_POST['submit'])) { $name = $_POST['name']; $visitor_email = $_POST['email']; $visitor_q1 = $_POST['q1']; $user_message = $_POST['message']; $gender = $_POST['gender']; ///------------Do Validations------------- if(empty($name)||empty($visitor_email)) { $errors .= "\n Name and Email are required fields. "; } if(IsInjected($visitor_email)) { $errors .= "\n Bad email value!"; } if(empty($_SESSION['6_letters_code'] ) || strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0) { //Note: the captcha code is compared case insensitively. //if you want case sensitive match, update the check above to // strcmp() $errors .= "\n The captcha code does not match!"; } if(empty($errors)) { //send the email $to = $your_email; $subject="New form submission"; $from = $your_email; $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $body = "A user $name submitted the contact form:\n". "Full Name: $name\n". "Email: $visitor_email \n". "Gender: $male \n". "Language: $lang \n". "Q1: $visitor_q1 \n". "Message: \n ". "$user_message\n". "IP: $ip\n"; $headers = "From: $from \r\n"; $headers .= "Reply-To: $visitor_email \r\n"; mail($to, $subject, $body,$headers); header('Location: thank-you.html'); } } // Function to validate against any email injection attempts function IsInjected($str) { $injections = array('(\n+)', '(\r+)', '(\t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } } ?> The Form <form method="POST" name="contact_form" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> <p> <label for='name'>Full Name: </label><br> <input type="text" name="name" value='<?php echo htmlentities($name) ?>'> </p> <p> <label for='email'>Email: </label><br> <input type="text" name="email" value='<?php echo htmlentities($visitor_email) ?>'> <p> <p> <label for='q1'>Q1: </label><br> <input type="text" name="q1" value='<?php echo htmlentities($visitor_q1) ?>'> <p> <label for='gender'>Male: </label> <input type="radio" name="Gender" value="male" <?php echo $_POST['gender'] == 'male' ? 'selected="selected"' : ''; ?>/> <br /> <label for='Gender'>Female:</label> <input type="radio" name="Gender" value="female" <?php echo $_POST['gender'] == 'female' ? 'selected="selected"' : ''; ?>/> <p>I speak the following languages: </p> <p> <input type="checkbox" name="lang" value='<?php echo htmlentities($en) ?>'/> English<br /> <input type="checkbox" name="lang" value='<?php echo htmlentities($fr) ?>'/> Français<br /> <input type="checkbox" name="lang" value='<?php echo htmlentities($es) ?>'/> Español<br /> </p> <p>My preferred language is: </p> <p> <input type="radio" name="pref" value="en" checked> English<br /> <input type="radio" name="pref" value="fr"> Français<br /> <input type="radio" name="pref" value="es"> Español<br /> </p> <p> <label for='message'>Message:</label> <br> <textarea name="message" rows=8 cols=30><?php echo htmlentities($user_message) ?></textarea> </p> <p> <img src="captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg' ><br> <label for='message'>Enter the code above here :</label><br> <input id="6_letters_code" name="6_letters_code" type="text"><br> <small>Can't read the image? click <a href='javascript: refreshCaptcha();'>here</a> to refresh</small> </p> <input type="submit" value="Submit" name='submit'> </form>
  17. Because I really don't understand how to make the radio buttons work and I was following with the existing code. I think this is where I would need some type of if else statement
  18. Thank you for that insight. I have it so it prints to the email but it only prints ,male Somewhere i think i need an if else statement but I don't know where it would go I tried putting one in the code above the header but it gave me errors This is what my sent email is printing at this point The choice of male and female is not correct A user gary submitted the contact form: Full Name: gary Email: test@testing.com Gender: ,male Language: Q1: an ans Message: test IP: 74.74.118.219 Code above header <?php $your_email ='gwhite@dezinezone2002.com';// <<=== update to your email address session_start(); $errors = ''; $name = ''; $visitor_email = ''; $user_message = ''; if(isset($_POST['submit'])) { $name = $_POST['name']; $visitor_email = $_POST['email']; $visitor_q1 = $_POST['q1']; $user_message = $_POST['message']; $gender = $_POST['gender']; ///------------Do Validations------------- if(empty($name)||empty($visitor_email)) { $errors .= "\n Name and Email are required fields. "; } if(IsInjected($visitor_email)) { $errors .= "\n Bad email value!"; } if(empty($_SESSION['6_letters_code'] ) || strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0) { //Note: the captcha code is compared case insensitively. //if you want case sensitive match, update the check above to // strcmp() $errors .= "\n The captcha code does not match!"; } if(empty($errors)) { //send the email $to = $your_email; $subject="New form submission"; $from = $your_email; $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $body = "A user $name submitted the contact form:\n". "Full Name: $name\n". "Email: $visitor_email \n". "Gender: $female,male \n". "Language: $lang \n". "Q1: $visitor_q1 \n". "Message: \n ". "$user_message\n". "IP: $ip\n"; $headers = "From: $from \r\n"; $headers .= "Reply-To: $visitor_email \r\n"; mail($to, $subject, $body,$headers); header('Location: thank-you.html'); } } // Function to validate against any email injection attempts function IsInjected($str) { $injections = array('(\n+)', '(\r+)', '(\t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } } ?> Code in header <script language="JavaScript" src="scripts/gen_validatorv31.js" type="text/javascript"></script> php in body <?php if(!empty($errors)){ echo "<p class='err'>".nl2br($errors)."</p>"; } ?> Form in body <form method="POST" name="contact_form" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> <p> <label for='name'>Full Name: </label><br> <input type="text" name="name" value='<?php echo htmlentities($name) ?>'> </p> <p> <label for='email'>Email: </label><br> <input type="text" name="email" value='<?php echo htmlentities($visitor_email) ?>'> <p> <p> <label for='q1'>Q1: </label><br> <input type="text" name="q1" value='<?php echo htmlentities($visitor_q1) ?>'> <p> <p> <label for='Gender'>Male: </label> <input type="radio" name="gender" value='<?php echo htmlentities($male) ?>'/> <br /> <label for='Gender'>Female:</label> <input type="radio" name="gender" value='<?php echo htmlentities($female) ?>'/> <br /> </p> <p>I speak the following languages: </p> <p> <input type="checkbox" name="lang" value='<?php echo htmlentities($en) ?>'/> English<br /> <input type="checkbox" name="lang" value='<?php echo htmlentities($fr) ?>'/> Français<br /> <input type="checkbox" name="lang" value='<?php echo htmlentities($es) ?>'/> Español<br /> </p> <p>My preferred language is: </p> <p> <input type="radio" name="pref" value="en" checked> English<br /> <input type="radio" name="pref" value="fr"> Français<br /> <input type="radio" name="pref" value="es"> Español<br /> </p> <p> <label for='message'>Message:</label> <br> <textarea name="message" rows=8 cols=30><?php echo htmlentities($user_message) ?></textarea> </p> <p> <img src="captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg' ><br> <label for='message'>Enter the code above here :</label><br> <input id="6_letters_code" name="6_letters_code" type="text"><br> <small>Can't read the image? click <a href='javascript: refreshCaptcha();'>here</a> to refresh</small> </p> <input type="submit" value="Submit" name='submit'> </form> validation in body <script language="JavaScript"> // Code for validating the form // Visit http://www.javascript-coder.com/html-form/javascript-form-validation.phtml // for details var frmvalidator = new Validator("contact_form"); //remove the following two lines if you like error message box popups frmvalidator.EnableOnPageErrorDisplaySingleBox(); frmvalidator.EnableMsgsTogether(); frmvalidator.addValidation("name","req","Please provide your name"); frmvalidator.addValidation("email","req","Please provide your email"); frmvalidator.addValidation("email","email","Please enter a valid email address"); </script> <script language='JavaScript' type='text/javascript'> function refreshCaptcha() { var img = document.images['captchaimg']; img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000; } </script> This is the entire page <?php $your_email ='gwhite@dezinezone2002.com';// <<=== update to your email address session_start(); $errors = ''; $name = ''; $visitor_email = ''; $user_message = ''; if(isset($_POST['submit'])) { $name = $_POST['name']; $visitor_email = $_POST['email']; $visitor_q1 = $_POST['q1']; $user_message = $_POST['message']; $gender = $_POST['gender']; ///------------Do Validations------------- if(empty($name)||empty($visitor_email)) { $errors .= "\n Name and Email are required fields. "; } if(IsInjected($visitor_email)) { $errors .= "\n Bad email value!"; } if(empty($_SESSION['6_letters_code'] ) || strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0) { //Note: the captcha code is compared case insensitively. //if you want case sensitive match, update the check above to // strcmp() $errors .= "\n The captcha code does not match!"; } if(empty($errors)) { //send the email $to = $your_email; $subject="New form submission"; $from = $your_email; $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $body = "A user $name submitted the contact form:\n". "Full Name: $name\n". "Email: $visitor_email \n". "Gender: $female,male \n". "Language: $lang \n". "Q1: $visitor_q1 \n". "Message: \n ". "$user_message\n". "IP: $ip\n"; $headers = "From: $from \r\n"; $headers .= "Reply-To: $visitor_email \r\n"; mail($to, $subject, $body,$headers); header('Location: thank-you.html'); } } // Function to validate against any email injection attempts function IsInjected($str) { $injections = array('(\n+)', '(\r+)', '(\t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"> <META name="description" content="Voice Lessons with Richard Fink IV world wide via Skype and iChat. Vocal studio located near Rochester NY."> <META name="keywords" content="rates, cost, vocal, teacher, coach, voice, private, lessons, rochester, ny, skype, ichat, new york city, los angels, las vegas, nyc, la, artist, pop, r&b, rock, country, metal"> <META NAME="GENERATOR" Content="Visual Page 2.0 for Windows"> <TITLE>Frequently Asked Questions | Vocal Coach | Castle Nine Vocal Studios</TITLE> <style type="text/css"> <!-- body,td,th { color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: medium; } body { background-color: #FFFFFF; } .style9 {font-size: 14px} .style18 {font-size: 25px; color: #330033; } .style20 {font-size: 24px} .style21 { font-size: 12px; font-style: italic; } .style23 {color: #000000} .style10 {color: #330033} .style11 { color: #330033; font-weight: bold; } --> </style> <style> label,a, body { font-family : Arial, Helvetica, sans-serif; font-size : 12px; } .err { font-family : Verdana, Helvetica, sans-serif; font-size : 12px; color: red; } </style> <script type="text/JavaScript"> <!-- function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //--> </script> <script language="JavaScript" src="scripts/gen_validatorv31.js" type="text/javascript"></script> </HEAD> <BODY LINK="#330066" VLINK="#330066" ALINK="red" onLoad="MM_preloadImages('images/pdalinkbio2.jpg','images/pdalinkhome2.jpg','images/pdalinkvocal2.jpg','images/pdalinkphotos2.jpg','images/pdalinktest2.jpg','images/pdalinkfaq2.jpg')"> <CENTER> <table border="0" align="center" cellpadding="5"> <tr> <td width="647" height="817" bgcolor="#CCCCCC"><table width="647" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="647" align="center" valign="top" bgcolor="#FFFFFF"><div align="center"><img src="images/pdaheading.jpg" width="647" height="158"><a href="http://www.richardiv.com/index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image11','','images/pdalinkhome2.jpg',1)"><img src="images/pdalinkhome.jpg" name="Image11" width="61" height="16" border="0"></a><a href="http://www.richardiv.com/richardfinkiv.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image10','','images/pdalinkbio2.jpg',1)"><img src="images/pdalinkbio.jpg" name="Image10" width="110" height="16" border="0"></a><a href="http://www.richardiv.com/voicelessons.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image12','','images/pdalinkvocal2.jpg',1)"><img src="images/pdalinkvocal.jpg" name="Image12" width="145" height="16" border="0"></a><a href="http://www.richardiv.com/photos.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image13','','images/pdalinkphotos2.jpg',1)"><img src="images/pdalinkphotos.jpg" width="146" height="16" border="0"></a><a href="http://www.richardiv.com/testimonials.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image14','','images/pdalinktest2.jpg',1)"><img src="images/pdalinktest.jpg" name="Image14" width="130" height="16" border="0"></a><a href="http://www.richardiv.com/faq.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image15','','images/pdalinkfaq2.jpg',1)"><img src="images/pdalinkfaq.jpg" name="Image15" width="55" height="16" border="0"></a><span class="style18"><br> </span><br> </div></td> </tr> <tr> <td height="601" bgcolor="#FFFFFF"><table width="644" border="0" align="center" cellpadding="5"> <tr> <td width="630" height="597"><p align="justify" class="style9"><span class="style18"><span class="style20"><span class="style23"> <?php if(!empty($errors)){ echo "<p class='err'>".nl2br($errors)."</p>"; } ?> <div id='contact_form_errorloc' class='err'></div> <form method="POST" name="contact_form" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> <p> <label for='name'>Full Name: </label><br> <input type="text" name="name" value='<?php echo htmlentities($name) ?>'> </p> <p> <label for='email'>Email: </label><br> <input type="text" name="email" value='<?php echo htmlentities($visitor_email) ?>'> <p> <p> <label for='q1'>Q1: </label><br> <input type="text" name="q1" value='<?php echo htmlentities($visitor_q1) ?>'> <p> <p> <label for='Gender'>Male: </label> <input type="radio" name="gender" value='<?php echo htmlentities($male) ?>'/> <br /> <label for='Gender'>Female:</label> <input type="radio" name="gender" value='<?php echo htmlentities($female) ?>'/> <br /> </p> <p>I speak the following languages: </p> <p> <input type="checkbox" name="lang" value='<?php echo htmlentities($en) ?>'/> English<br /> <input type="checkbox" name="lang" value='<?php echo htmlentities($fr) ?>'/> Français<br /> <input type="checkbox" name="lang" value='<?php echo htmlentities($es) ?>'/> Español<br /> </p> <p>My preferred language is: </p> <p> <input type="radio" name="pref" value="en" checked> English<br /> <input type="radio" name="pref" value="fr"> Français<br /> <input type="radio" name="pref" value="es"> Español<br /> </p> <p> <label for='message'>Message:</label> <br> <textarea name="message" rows=8 cols=30><?php echo htmlentities($user_message) ?></textarea> </p> <p> <img src="captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg' ><br> <label for='message'>Enter the code above here :</label><br> <input id="6_letters_code" name="6_letters_code" type="text"><br> <small>Can't read the image? click <a href='javascript: refreshCaptcha();'>here</a> to refresh</small> </p> <input type="submit" value="Submit" name='submit'> </form></i><br> <br> <br> <br> </p> </td> </tr> </table> </td> </tr> <tr> <td><img src="images/pdabase.jpg" width="647" height="48" border="0" usemap="#Map2"></td> </tr> </table> </td> </tr> </table> </CENTER> <map name="Map"><area shape="rect" coords="514,43,633,70" href="richard_fink_iv/voicelessons.htm"> <area shape="rect" coords="514,74,637,96" href="richard_fink_iv/photo.htm"> <area shape="rect" coords="529,101,637,124" href="richard_fink_iv/testimonials.htm"> <area shape="rect" coords="581,128,638,150" href="richard_fink_iv/faq.htm"> <area shape="rect" coords="152,52,462,113" href="richard_fink_iv/mobileindex.html"> </map> <map name="Map2"><area shape="rect" coords="462,7,503,46" href="http://www.facebook.com/pages/Richard-Fink-IV-Vocal-Coach/165219796824660"> <area shape="rect" coords="509,5,550,47" href="http://www.myspace.com/richardfinkiv"> <area shape="rect" coords="558,6,596,48" href="http://www.twitter.com/richardfinkiv"> <area shape="rect" coords="607,6,647,47" href="http://www.youtube.com/richardfinkiv"> </map> <map name="Map3"><area shape="rect" coords="-5,-1,129,67" href="http://www.skype.com"> <area shape="rect" coords="135,1,213,77" href="http://www.apple.com"> </map> <map name="Map4"><area shape="rect" coords="497,16,647,151" href="index.html"> </map> <script language="JavaScript"> // Code for validating the form // Visit http://www.javascript-coder.com/html-form/javascript-form-validation.phtml // for details var frmvalidator = new Validator("contact_form"); //remove the following two lines if you like error message box popups frmvalidator.EnableOnPageErrorDisplaySingleBox(); frmvalidator.EnableMsgsTogether(); frmvalidator.addValidation("name","req","Please provide your name"); frmvalidator.addValidation("email","req","Please provide your email"); frmvalidator.addValidation("email","email","Please enter a valid email address"); </script> <script language='JavaScript' type='text/javascript'> function refreshCaptcha() { var img = document.images['captchaimg']; img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000; } </script> </BODY> </HTML>
  19. Any detailed help for a newbie would be greatly appreciated.
  20. php is new to me and i;m not very good at it yet. I was able to piece this togher with snippets of code but now I am stuck and have no idea where to put $gender = $_POST['Gender']; I tried putting it in several places I thought would work but no luck
  21. Ok I have defined it here like so and it still will not process it when the email is sent //send the email $to = $your_email; $subject="New form submission"; $from = $your_email; $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $body = "A user $name submitted the contact form:\n". "Full Name: $name\n". "Email: $visitor_email \n". "Gender: $gender \n". "Language: $lang \n". "Q1: $visitor_q1 \n". "Message: \n ". "$user_message\n". "IP: $ip\n"; $headers = "From: $from \r\n"; $headers .= "Reply-To: $visitor_email \r\n"; mail($to, $subject, $body,$headers); header('Location: thank-you.html'); } } -------------------------------------------------------------- Here is what is returned A user gary submitted the contact form: Full Name: gary Email: gwthsjkh@jkskd.com Gender: Language: Q1: the ands Message: test IP: 74.74.118.219
  22. Below is my code. I am having an issue with the form printing the Gender to an e-mail that it sends. I can't figure out what I am missing. Everything else works fine. I also need to have a list of check boxes that more than one can be selected like What kind of music do you like? Rock Pop ETC Any help with this would be greatly appreciated Thank you Gary Code below ----------------------------------------------------------------------------------------- <?php $your_email ='email@emailaddress.com';// <<=== update to your email address session_start(); $errors = ''; $name = ''; $visitor_email = ''; $user_message = ''; if(isset($_POST['submit'])) { $name = $_POST['name']; $visitor_email = $_POST['email']; $visitor_q1 = $_POST['q1']; $user_message = $_POST['message']; ///------------Do Validations------------- if(empty($name)||empty($visitor_email)) { $errors .= "\n Name and Email are required fields. "; } if(IsInjected($visitor_email)) { $errors .= "\n Bad email value!"; } if(empty($_SESSION['6_letters_code'] ) || strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0) { //Note: the captcha code is compared case insensitively. //if you want case sensitive match, update the check above to // strcmp() $errors .= "\n The captcha code does not match!"; } if(empty($errors)) { //send the email $to = $your_email; $subject="New form submission"; $from = $your_email; $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $body = "A user $name submitted the contact form:\n". "Full Name: $name\n". "Email: $visitor_email \n". "Gender: $gender \n". "Q1: $visitor_q1 \n". "Message: \n ". "$user_message\n". "IP: $ip\n"; $headers = "From: $from \r\n"; $headers .= "Reply-To: $visitor_email \r\n"; mail($to, $subject, $body,$headers); header('Location: thank-you.html'); } } // Function to validate against any email injection attempts function IsInjected($str) { $injections = array('(\n+)', '(\r+)', '(\t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"> <META name="description" content="Voice Lessons with Richard Fink IV world wide via Skype and iChat. Vocal studio located near Rochester NY."> <META name="keywords" content="rates, cost, vocal, teacher, coach, voice, private, lessons, rochester, ny, skype, ichat, new york city, los angels, las vegas, nyc, la, artist, pop, r&b, rock, country, metal"> <META NAME="GENERATOR" Content="Visual Page 2.0 for Windows"> <TITLE>Frequently Asked Questions | Vocal Coach | Castle Nine Vocal Studios</TITLE> <style type="text/css"> <!-- body,td,th { color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: medium; } body { background-color: #FFFFFF; } .style9 {font-size: 14px} .style18 {font-size: 25px; color: #330033; } .style20 {font-size: 24px} .style21 { font-size: 12px; font-style: italic; } .style23 {color: #000000} .style10 {color: #330033} .style11 { color: #330033; font-weight: bold; } --> </style> <style> label,a, body { font-family : Arial, Helvetica, sans-serif; font-size : 12px; } .err { font-family : Verdana, Helvetica, sans-serif; font-size : 12px; color: red; } </style> <script type="text/JavaScript"> <!-- function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //--> </script> <script language="JavaScript" src="scripts/gen_validatorv31.js" type="text/javascript"></script> </HEAD> <BODY LINK="#330066" VLINK="#330066" ALINK="red" onLoad="MM_preloadImages('images/pdalinkbio2.jpg','images/pdalinkhome2.jpg','images/pdalinkvocal2.jpg','images/pdalinkphotos2.jpg','images/pdalinktest2.jpg','images/pdalinkfaq2.jpg')"> <CENTER> <table border="0" align="center" cellpadding="5"> <tr> <td width="647" height="817" bgcolor="#CCCCCC"><table width="647" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="647" align="center" valign="top" bgcolor="#FFFFFF"><div align="center"><img src="images/pdaheading.jpg" width="647" height="158"><a href="http://www.richardiv.com/index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image11','','images/pdalinkhome2.jpg',1)"><img src="images/pdalinkhome.jpg" name="Image11" width="61" height="16" border="0"></a><a href="http://www.richardiv.com/richardfinkiv.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image10','','images/pdalinkbio2.jpg',1)"><img src="images/pdalinkbio.jpg" name="Image10" width="110" height="16" border="0"></a><a href="http://www.richardiv.com/voicelessons.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image12','','images/pdalinkvocal2.jpg',1)"><img src="images/pdalinkvocal.jpg" name="Image12" width="145" height="16" border="0"></a><a href="http://www.richardiv.com/photos.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image13','','images/pdalinkphotos2.jpg',1)"><img src="images/pdalinkphotos.jpg" width="146" height="16" border="0"></a><a href="http://www.richardiv.com/testimonials.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image14','','images/pdalinktest2.jpg',1)"><img src="images/pdalinktest.jpg" name="Image14" width="130" height="16" border="0"></a><a href="http://www.richardiv.com/faq.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image15','','images/pdalinkfaq2.jpg',1)"><img src="images/pdalinkfaq.jpg" name="Image15" width="55" height="16" border="0"></a><span class="style18"><br> </span><br> </div></td> </tr> <tr> <td height="601" bgcolor="#FFFFFF"><table width="644" border="0" align="center" cellpadding="5"> <tr> <td width="630" height="597"><p align="justify" class="style9"><span class="style18"><span class="style20"><span class="style23"><?php if(!empty($errors)){ echo "<p class='err'>".nl2br($errors)."</p>"; } ?> <div id='contact_form_errorloc' class='err'></div> <form method="POST" name="contact_form" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> <p> <label for='name'>Full Name: </label><br> <input type="text" name="name" value='<?php echo htmlentities($name) ?>'> </p> <p> <label for='email'>Email: </label><br> <input type="text" name="email" value='<?php echo htmlentities($visitor_email) ?>'> <p> <p> <label for='q1'>Q1: </label><br> <input type="text" name="q1" value='<?php echo htmlentities($visitor_q1) ?>'> <p> <p> <label for='gender'>Male: </label> <input type="radio" name="Gender" value='<?php echo htmlentities($male) ?>'/> <br /> <label for='Gender'>Female:</label> <input type="radio" name="Gender" value='<?php echo htmlentities($female) ?>'/> <br /> </p> <p> <label for='message'>Message:</label> <br> <textarea name="message" rows=8 cols=30><?php echo htmlentities($user_message) ?></textarea> </p> <p> <img src="captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg' ><br> <label for='message'>Enter the code above here :</label><br> <input id="6_letters_code" name="6_letters_code" type="text"><br> <small>Can't read the image? click <a href='javascript: refreshCaptcha();'>here</a> to refresh</small> </p> <input type="submit" value="Submit" name='submit'> </form></i><br> <br> <br> <br> </p> </td> </tr> </table> </td> </tr> <tr> <td><img src="images/pdabase.jpg" width="647" height="48" border="0" usemap="#Map2"></td> </tr> </table> </td> </tr> </table> </CENTER> <map name="Map"><area shape="rect" coords="514,43,633,70" href="richard_fink_iv/voicelessons.htm"> <area shape="rect" coords="514,74,637,96" href="richard_fink_iv/photo.htm"> <area shape="rect" coords="529,101,637,124" href="richard_fink_iv/testimonials.htm"> <area shape="rect" coords="581,128,638,150" href="richard_fink_iv/faq.htm"> <area shape="rect" coords="152,52,462,113" href="richard_fink_iv/mobileindex.html"> </map> <map name="Map2"><area shape="rect" coords="462,7,503,46" href="http://www.facebook.com/pages/Richard-Fink-IV-Vocal-Coach/165219796824660"> <area shape="rect" coords="509,5,550,47" href="http://www.myspace.com/richardfinkiv"> <area shape="rect" coords="558,6,596,48" href="http://www.twitter.com/richardfinkiv"> <area shape="rect" coords="607,6,647,47" href="http://www.youtube.com/richardfinkiv"> </map> <map name="Map3"><area shape="rect" coords="-5,-1,129,67" href="http://www.skype.com"> <area shape="rect" coords="135,1,213,77" href="http://www.apple.com"> </map> <map name="Map4"><area shape="rect" coords="497,16,647,151" href="index.html"> </map> <script language="JavaScript"> // Code for validating the form // Visit http://www.javascript-coder.com/html-form/javascript-form-validation.phtml // for details var frmvalidator = new Validator("contact_form"); //remove the following two lines if you like error message box popups frmvalidator.EnableOnPageErrorDisplaySingleBox(); frmvalidator.EnableMsgsTogether(); frmvalidator.addValidation("name","req","Please provide your name"); frmvalidator.addValidation("email","req","Please provide your email"); frmvalidator.addValidation("email","email","Please enter a valid email address"); </script> <script language='JavaScript' type='text/javascript'> function refreshCaptcha() { var img = document.images['captchaimg']; img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000; } </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.