Jump to content

welchyboy

Members
  • Posts

    16
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

welchyboy's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I understand you do not always test the code you provide and I can understand you are very busy. I am not complaining by any means just very new as I stated still learning my way around php and html for that matter. I have got the code working just the way I like and modified the email which is sent out. For some reason I do not get the javascript pop up box but all the php validation is working and that is all I need. I THANK YOU so MUCH for all the help and really walking me through this form. The customers I have provided this form are very pleased and I have learned a great deal as well. I am marking this thread as successful
  2. I am having trouble getting it to fully work the way it should. Right now it sends and email but the check boxes all say no and it doesn't matter whether they are checked or not. Also for some reason one of the pieces of code i put in prevents the javascript box from coming on. The way I have it right now is it does require a user to fill in at least one check box but it is not displaying properly in the email. If you could see if I have all the code placed properly. I had a hard time trying to figure out which document and which place they needed to go. I think I have it correct but I must have missed something... index.php <?php //Load the countries list require('email_countries.php'); function is_email($email) { $formatTest = '/^[-\w+]+(\.[-\w+]+)*@[-a-z\d]{2,}(\.[-a-z\d]{2,})*\.[a-z]{2,6}$/i'; $lengthTest = '/^(.{1,64})@(.{4,255})$/'; return (preg_match($formatTest, $email) && preg_match($lengthTest, $email)); } if (isset($_POST['form_id'])) { //Create array variable for errors $errors = array(); $error_msg = ''; //Posted variables $Name = trim($_POST["Name"]); $Address = trim($_POST["Address"]); $Address2 = trim($_POST["Address2"]); $City = trim($_POST["City"]); $State = trim($_POST["State"]); $Country = trim($_POST["Country"]); $Zip = trim($_POST["Zip"]); $Phone = trim($_POST["Phone"]); $Email = trim($_POST["Email"]) ; $Brochure1 = trim($_POST["Brochure1"]) ; $Brochure2 = trim($_POST["Brochure2"]) ; $Brochure3 = trim($_POST["Brochure3"]) ; $Brochure4 = trim($_POST["Brochure4"]) ; //Validate the posted values if (empty($Name)) { $errors[] = "Name is required."; } if (empty($Address)) { $errors[] = "Address is required."; } if (empty($City)) { $errors[] = "City is required."; } if (empty($State)) { $errors[] = "State is required."; } if (!in_array($Country, $countries)) { $errors[] = "Country is required."; } if (empty($Email)) { $errors[] = "Email is required."; } else if (!is_email($Email)) { $errors[] = "Email is invalid."; } if(!isset($_POST['selections'])) { $errors[] = "Must select at least one option."; } //Create error message if needed if (count($errors)>0) { $error_msg = "The following errors occured. Please correct and resubmit the form:<br />\n"; $error_msg .= "<ul><li>" . implode("</li>\n<li>", $errors) . "</li></ul>"; } else { //There were no errors send the data $recipient = "test@test.com"; $subject = "Request A Brochure"; $headers = 'From: <webmaster@example.com>' . "\r\n"; $forminfo = "Name: $Name\n"; $forminfo .= "Address: $Address\n"; $forminfo .= "Address2: $Address2\n"; $forminfo .= "City: $City\n"; $forminfo .= "State: $State\n"; $forminfo .= "Country: $Country\n"; $forminfo .= "Zip: $Zip\n"; $forminfo .= "Phone: $Phone\n"; $forminfo .= "Email: $Email\n\n"; $optionsList = array('Option 1','Option 2','Option 3'); foreach($optionsList as $option) { $forminfo .= "$option: " . ((in_array($option, $_POST['options']))?'Yes':'No') . "\n"; } $forminfo .= "Form Submitted: " . date('M d, Y') . "\n\n"; $formsend = mail("$recipient", "$subject", "$forminfo", "From: $email\r\nReply-to:$email"); //Create confirmation/error page if ($formsend) { $title = "Thank you"; $refresh = "<meta http-equiv=\"refresh\" content=\"5; URL=index.php?main_page=request_a_brochure\">"; $content = "Thank you. You submission has been complete. Redirecting..."; } else //Problem sending email { $title = "Submission error"; $content = "There was a problem sending your submission."; $refresh = ""; } //Show email confirmation/error page require('email_confirm.php'); exit(); } } //Page was not posted or there was an error require('email_form.php'); ?> email_form.php <?php function createSelectOptions($options, $selectedOption) { foreach ($options as $option) { $selected = ($option == $selectedOption)? ' selected="selected"': ''; echo "<option value=\"$option\"$selected>$option</option>\n"; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Request A Brochure</title> <link rel="stylesheet" type="text/css" href="http://www.stxmilling.com/view.css" media="all"> <script type="text/javascript" src="http://www.stxmilling.com/view.js"></script> <script type="text/javascript"> String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,''); } function validEmail(emailStr) { //Return true/false for valid/invalid email formatTest = /^[\w`\-=~!#$%^&*'+{}|'/?]+(\.[\w`\-=~!#$%^&*'+{}|'/?]+)*@[-a-z\d]{2,}(\.[-a-z\d]{2,})*\.[a-z]{2,6}$/i lengthTest = /^(.{1,64})@(.{4,255})$/ return (formatTest.test(emailStr) && lengthTest.test(emailStr)); } function validateForm(formObj) { var errors = new Array(); if(formObj.Name.value.trim()=='') { errors[errors.length] = 'Name is required'; } if(formObj.Address.value.trim()=='') { errors[errors.length] = 'Address is required'; } if(formObj.Zip.value.trim()=='') { errors[errors.length] = 'Zip Code is required'; } if(formObj.City.value.trim()=='') { errors[errors.length] = 'City is required'; } if(formObj.State.value.trim()=='') { errors[errors.length] = 'State is required'; } if(formObj.Country.value.trim()=='') { errors[errors.length] = 'Country is required'; } if(formObj.Email.value.trim()=='') { errors[errors.length] = 'Email is required'; } else if(!validEmail(formObj.Email.value.trim())) { errors[errors.length] = 'Email is invalid'; } if(f!optionSelected(formObj['selections[]'])) { errors[errors.length] = 'Must select at least one option.'; } if(errors.length>0) { errorMsg = 'The following errors occured:\n'; errorMsg += '<ul><li>' + errors.join('</li><li>') + '</li></ul>'; document.getElementById('errors').innerHTML = errorMsg; alert('There were errors. Please correct and resubmit.'); return false; } return true; } function optionSelected(checkGroup) { for(var i=0; i<checkGroup.length; i++) { if (checkGroup[i].checked) { return true; } } return false; } </script> </head> <body id="main_body" > <br /><br /> <div id="form_container"> <div id="errors"><?php echo $error_msg; ?></div> <form id="form_14512" class="appnitro" method="post" action="" onsubmit="return validateForm(this)"> <div class="form_description"> <h2>Request A Brochure</h2> </div> <ul> <li id="li_1" > <label class="description" for="Name">* Name </label> <div> <input id="Name" name="Name" class="element text medium" type="text" maxlength="255" value="<?php echo $Name; ?>"/> </div> <p class="guidelines" id="guide_1"><small>Enter your name</small></p> </li> <li id="li_2" > <label class="description" for="element_2">* Mailing Address </label> <div> <input id="Address" name="Address" class="element text large" value="<?php echo $Address; ?>" type="text"> <strong><label for="Address">* Street Address</label></strong> </div> <div> <input id="Address2" name="Address2" class="element text large" value="<?php echo $Address2; ?>" type="text"> <label for="Address2">Address Line 2</label> </div> <div class="left"><strong> <input id="City" name="City" class="element text medium" value="<?php echo $City; ?>" type="text"> <strong><label for="City">* City</label></strong> </div> <div class="right"><strong> <input id="State" name="State" class="element text medium" value="<?php echo $State; ?>" type="text"> <label for="State">* State / Province / Region</label></strong> </div> <div class="left"><strong> <input id="Zip" name="Zip" class="element text medium" maxlength="15" value="<?php echo $Zip; ?>" type="text"> <strong><label for="Zip">* Postal / Zip Code</label></strong> </div> <div class="right"><strong> <select class="element select medium" id="Country" name="Country"> <option value="" selected="selected"></option> <?php createSelectOptions($countries, $Country); ?> </select> <strong><label for="Country">* Country</label></strong> </div> <p class="guidelines" id="guide_2"><small>Enter your mailing address</small></p> </li> <li id="li_3" > <label class="description" for="Phone">Phone Number </label> <div> <input id="Phone" name="Phone" class="element text medium" type="text" maxlength="255" value="<?php echo $Phone; ?>"/> </div> <p class="guidelines" id="guide_3"><small>Enter your phone number</small></p> </li> <li id="li_4" > <label class="description" for="Email">* Email </label> <div> <input id="Email" name="Email" class="element text medium" type="text" maxlength="255" value="<?php echo $Email; ?>"/> </div> <p class="guidelines" id="guide_4"><small>Enter your email address</small></p> </li> <input type="checkbox" name="selections[]" value="item 1" /> Item 1<br /> <input type="checkbox" name="selections[]" value="item 2" /> Item 2<br /> <input type="checkbox" name="selections[]" value="item 3" /> Item 3<br /> <li class="buttons"> <input type="hidden" name="form_id" value="14512" /> <input value="Submit form" type="submit" /> </li> </ul> </form> <div id="footer"></div> </div> </body> </html> If you could help me out to get this a little more perfected on my end then I will be so happy and through bothering you. Thanks again I really really really do appreciate your time and help with this
  3. I guess I should post the new changed files index.php <?php //Load the countries list require('email_countries.php'); function is_email($email) { $formatTest = '/^[-\w+]+(\.[-\w+]+)*@[-a-z\d]{2,}(\.[-a-z\d]{2,})*\.[a-z]{2,6}$/i'; $lengthTest = '/^(.{1,64})@(.{4,255})$/'; return (preg_match($formatTest, $email) && preg_match($lengthTest, $email)); } if (isset($_POST['form_id'])) { //Create array variable for errors $errors = array(); $error_msg = ''; //Posted variables $Name = trim($_POST["Name"]); $Address = trim($_POST["Address"]); $Address2 = trim($_POST["Address2"]); $City = trim($_POST["City"]); $State = trim($_POST["State"]); $Country = trim($_POST["Country"]); $Zip = trim($_POST["Zip"]); $Phone = trim($_POST["Phone"]); $Email = trim($_POST["Email"]) ; $Brochure1 = trim($_POST["Brochure1"]) ; $Brochure2 = trim($_POST["Brochure2"]) ; $Brochure3 = trim($_POST["Brochure3"]) ; $Brochure4 = trim($_POST["Brochure4"]) ; //Validate the posted values if (empty($Name)) { $errors[] = "Name is required."; } if (empty($Address)) { $errors[] = "Address is required."; } if (empty($City)) { $errors[] = "City is required."; } if (empty($State)) { $errors[] = "State is required."; } if (!in_array($Country, $countries)) { $errors[] = "Country is required."; } if (empty($Email)) { $errors[] = "Email is required."; } else if (!is_email($Email)) { $errors[] = "Email is invalid."; } //Create error message if needed if (count($errors)>0) { $error_msg = "The following errors occured. Please correct and resubmit the form:<br />\n"; $error_msg .= "<ul><li>" . implode("</li>\n<li>", $errors) . "</li></ul>"; } else { //There were no errors send the data $recipient = "you@you.com"; $subject = "test subject line"; $headers = 'From: <webmaster@example.com>' . "\r\n"; $forminfo = "Name: $Name\n"; $forminfo .= "Address: $Address\n"; $forminfo .= "Address2: $Address2\n"; $forminfo .= "City: $City\n"; $forminfo .= "State: $State\n"; $forminfo .= "Country: $Country\n"; $forminfo .= "Zip: $Zip\n"; $forminfo .= "Phone: $Phone\n"; $forminfo .= "Email: $Email\n\n"; $forminfo .= "this is brochure 1: $Brochure1\n"; $forminfo .= "this is brochure 2: $Brochure2\n"; $forminfo .= "this is brochure 3: $Brochure3\n"; $forminfo .= "this is brochure 4: $Brochure4\n"; $forminfo .= "Form Submitted: " . date('M d, Y') . "\n\n"; $formsend = mail("$recipient", "$subject", "$forminfo", "From: $email\r\nReply-to:$email"); //Create confirmation/error page if ($formsend) { $title = "Thank you"; $refresh = "<meta http-equiv=\"refresh\" content=\"5; URL=index.php?main_page=request_a_brochure\">"; $content = "Thank you. You submission has been complete. Redirecting..."; } else //Problem sending email { $title = "Submission error"; $content = "There was a problem sending your submission."; $refresh = ""; } //Show email confirmation/error page require('email_confirm.php'); exit(); } } //Page was not posted or there was an error require('email_form.php'); ?> email_form.php <?php function createSelectOptions($options, $selectedOption) { foreach ($options as $option) { $selected = ($option == $selectedOption)? ' selected="selected"': ''; echo "<option value=\"$option\"$selected>$option</option>\n"; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Request A Brochure</title> <link rel="stylesheet" type="text/css" href="http://www.stxmilling.com/view.css" media="all"> <script type="text/javascript" src="http://www.stxmilling.com/view.js"></script> <script type="text/javascript"> String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,''); } function validEmail(emailStr) { //Return true/false for valid/invalid email formatTest = /^[\w`\-=~!#$%^&*'+{}|'/?]+(\.[\w`\-=~!#$%^&*'+{}|'/?]+)*@[-a-z\d]{2,}(\.[-a-z\d]{2,})*\.[a-z]{2,6}$/i lengthTest = /^(.{1,64})@(.{4,255})$/ return (formatTest.test(emailStr) && lengthTest.test(emailStr)); } function validateForm(formObj) { var errors = new Array(); if(formObj.Name.value.trim()=='') { errors[errors.length] = 'Name is required'; } if(formObj.Address.value.trim()=='') { errors[errors.length] = 'Address is required'; } if(formObj.Zip.value.trim()=='') { errors[errors.length] = 'Zip Code is required'; } if(formObj.City.value.trim()=='') { errors[errors.length] = 'City is required'; } if(formObj.State.value.trim()=='') { errors[errors.length] = 'State is required'; } if(formObj.Country.value.trim()=='') { errors[errors.length] = 'Country is required'; } if(formObj.Email.value.trim()=='') { errors[errors.length] = 'Email is required'; } else if(!validEmail(formObj.Email.value.trim())) { errors[errors.length] = 'Email is invalid'; } if(errors.length>0) { errorMsg = 'The following errors occured:\n'; errorMsg += '<ul><li>' + errors.join('</li><li>') + '</li></ul>'; document.getElementById('errors').innerHTML = errorMsg; alert('There were errors. Please correct and resubmit.'); return false; } return true; } </script> </head> <body id="main_body" > <br /><br /> <div id="form_container"> <div id="errors"><?php echo $error_msg; ?></div> <form id="form_14512" class="appnitro" method="post" action="" onsubmit="return validateForm(this)"> <div class="form_description"> <h2>Request A Brochure</h2> </div> <ul> <li id="li_1" > <label class="description" for="Name">* Name </label> <div> <input id="Name" name="Name" class="element text medium" type="text" maxlength="255" value="<?php echo $Name; ?>"/> </div> <p class="guidelines" id="guide_1"><small>Enter your name</small></p> </li> <li id="li_2" > <label class="description" for="element_2">* Mailing Address </label> <div> <input id="Address" name="Address" class="element text large" value="<?php echo $Address; ?>" type="text"> <strong><label for="Address">* Street Address</label></strong> </div> <div> <input id="Address2" name="Address2" class="element text large" value="<?php echo $Address2; ?>" type="text"> <label for="Address2">Address Line 2</label> </div> <div class="left"><strong> <input id="City" name="City" class="element text medium" value="<?php echo $City; ?>" type="text"> <strong><label for="City">* City</label></strong> </div> <div class="right"><strong> <input id="State" name="State" class="element text medium" value="<?php echo $State; ?>" type="text"> <label for="State">* State / Province / Region</label></strong> </div> <div class="left"><strong> <input id="Zip" name="Zip" class="element text medium" maxlength="15" value="<?php echo $Zip; ?>" type="text"> <strong><label for="Zip">* Postal / Zip Code</label></strong> </div> <div class="right"><strong> <select class="element select medium" id="Country" name="Country"> <option value="" selected="selected"></option> <?php createSelectOptions($countries, $Country); ?> </select> <strong><label for="Country">* Country</label></strong> </div> <p class="guidelines" id="guide_2"><small>Enter your mailing address</small></p> </li> <li id="li_3" > <label class="description" for="Phone">Phone Number </label> <div> <input id="Phone" name="Phone" class="element text medium" type="text" maxlength="255" value="<?php echo $Phone; ?>"/> </div> <p class="guidelines" id="guide_3"><small>Enter your phone number</small></p> </li> <li id="li_4" > <label class="description" for="Email">* Email </label> <div> <input id="Email" name="Email" class="element text medium" type="text" maxlength="255" value="<?php echo $Email; ?>"/> </div> <p class="guidelines" id="guide_4"><small>Enter your email address</small></p> </li> <input name='Brochure1' type='checkbox' id='Brochure1'value='Yes' <?php if($_POST['on'] == 'Yes') echo "Yes" ?> >Brochure1 <br /> <input name='Brochure2' type='checkbox' id='Brochure2'value='Yes' <?php if($_POST['on'] == 'Yes') echo "Yes" ?>>Brochure2 <br /> <input name='Brochure3' type='checkbox' id='Brochure3'value='Yes' <?php if($_POST['on'] == 'Yes') echo "Yes" ?>>Brochure3 <br /> <input name='Brochure4' type='checkbox' id='Brochure4'value='Yes' <?php if($_POST['on'] == 'Yes') echo "Yes" ?>>Brochure4 <br /> <li class="buttons"> <input type="hidden" name="form_id" value="14512" /> <input value="Submit form" type="submit" /> </li> </ul> </form> <div id="footer"></div> </div> </body> </html>
  4. OK I will mark the thread as solved although if I could ask a few more minor questions. I needed to add some check boxes for users to choose certain brochures. I have created the check boxes and spend quite a while trying to figure out ow to get it to send an email and show YES as in it is checked. But I have accomplished this. My only issue now is that I need to make sure at least one checkbox is selected. I do not know how to do this? I have searched but I am spending a lot of time and thought maybe you could quickly help. Also this is minor and not necessarily something that needs to be fixed but if simple I could use the help. The thank you message is kind of weird..for some reason it takes my right hand sidebar off completely. Is there an easier way to do a successful message other than this. And one more at the top of the page I have the word code in brackets I couldn't put what it was because it would actually create the code box in the forum. This is displayed on the main page and on the thank you page. I really do appreciate your help on this.
  5. Sorry for a THIRD POST IN A ROW lol but I got it!!! I needed to put index.php as the primary code...I did try that once but got a blank page but that was because I didn't have email_form.php uploaded because I was already using that code for the primary code. But anyways I got it all to work just the way I want and I can't Thank You enough! Not only did you help me but it forced me to learn more and more which is always a good thing. You can see the full working code here... stxm+illing.com/index.php?main_page=requ+est_a_broc+hure I know the redirect and so forth is not correct yet because the page name has been changed but I believe I can work out those minor changes. Again thank you so much for all your help!!
  6. Maybe if you could tell me what is actually calling the certain files maybe that will help. I see that index.php calls all the files. Like require('email_confirm.php'); and so forth. I see it calls all of the except index.php which of course that is the file. I changed the email_form.php to tpl_request_a_brochure_default.php which is the name of the new email_form.php just to see if that helped but it didn't make a difference. I am so close I just need to figure out where to put these files in the zen cart structure so it can see them and work correctly. Any thoughts on this? I will continue to search around and try different things. I will update if I have anything new. Thanks again for all the help.
  7. OK I have spent quite a bit of time working with your script and I have got it to show in zen cart now. Which is GREAT news!!! However I had to do it a special way and so I am not sure exactly where the other files should go so that it can access them. Let me explain a little more. Zen cart is created in php but you can not go into the zen cart admin portion of the site and just copy and paste php code into the page. It only accepts html for the most part. So I created a new page with a program specifically for zen cart. Then I pasted the email_form.php code into it. The form shows up and the errors are displayed which is GREAT!! However the additional files like email_countries and so forth are not being located. Because if I tried to click on the drop down menu for the countries none are displayed. I have put the main code in the same directory but like I said the structure and the way to create a page in zen cart is very confusing. So I am not sure exactly where these additional files need to go. I am not sure if you could even help me further on this issue since you are not very familiar with zen cart. Sorry if i confused you it was rather hard to explain
  8. does anybody know if there is a way to change this code to where it is pretty much the same but the actual form is in html so it can be put in a zen cart page? Please let me know. Thanks
  9. OK I actually really like this code and I appreciate you explaining the code. I am trying to learn more and more everyday. There is a slight problem which is not your fault I just failed to mention it. The site this form is going on is a zen cart e commerce site. I don't think straight php can be added into the pages. The form I have on there now is HTML and it calls the php files. Is this possible? Other than that I really do love it and appreciate your help. I could have never gotten this on my own. I have tried adding the code from the email_form.php into the zen cart page and it showed up blank. If i took just the information between the HTML tags it showed part of the form but not the entire thing. Any thoughts on working around this?
  10. Wow!! First off thanks for the help. Looks like a LOT of work. Here is the link again sorry about that. http://www.stxm+illing.com/index.php?main_page=cont+act_us_1 Take the two '+' signs out and it should work. I have modified the code a little more to ALMOST get what I am happy with and it looks like this. <? $Name = $_POST["Name"]; $Address = $_POST["Address"]; $Address2 = $_POST["Address2"]; $City = $_POST["City"]; $State = $_POST["State"]; $Country = $_POST["Country"]; $Zip = $_POST["Zip"]; $Phone = $_POST["Phone"]; $Email = $_POST["Email"]; $today = date("M d, Y"); $recipient = "me@me.com.com"; $subject = "Request a Brochure"; $headers = 'From: <webmaster@example.com>' . "\r\n"; $forminfo = "Name: $Name\n Address: $Address\n Address2: $Address2\n City: $City\n State: $State\n Country: $Country\n Zip: $Zip\n Phone: $Phone\n Email: $Email\n Form Submitted: $today\n\n"; if (!empty($_POST['Name'])){ $msg = "Name; $_POST[Name] "; }else{ $Name = NULL; echo "Please fill out your first name.<br />"; } if (!empty($_POST['Address'])){ $msg = "Address; $_POST[Address] "; }else{ $Address = NULL; echo "Please fill out your Address.<br />"; } if (!empty($_POST['City'])){ $msg = "City; $_POST[City] "; }else{ $City = NULL; echo "Please fill out your City.<br />"; } if (!empty($_POST['State'])){ $msg = "State; $_POST[state] "; }else{ $State = NULL; echo "Please fill out your State.<br />"; } if (!empty($_POST['zipcode'])){ $msg = "zipcode; $_POST[zipcode] "; }else{ $zipcode = NULL; echo "Please fill out your zipcode.<br />"; } if (!empty($_POST['Country'])){ $msg = "Country; $_POST[Country] "; }else{ $Country = NULL; echo "Please fill out your Country.<br />"; } /* if (!empty($_POST['Name'])){ $msg = ""; }else{ $Name = NULL; echo "Please fill out your first name.<br />"; echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?main_page=contact_us_1\">"; exit; } if (!empty($_POST['Address'])){ $msg = ""; }else{ $Name = NULL; echo "Please fill out your Street Name.<br />"; echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?main_page=contact_us_1\">"; exit; } if (!empty($_POST['City'])){ $msg = ""; }else{ $Name = NULL; echo "Please fill out your City.<br />"; echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?main_page=contact_us_1\">"; exit; } if (!empty($_POST['State'])){ $msg = ""; }else{ $Name = NULL; echo "Please fill out your State.<br />"; echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?main_page=contact_us_1\">"; exit; } if (!empty($_POST['Country'])){ $msg = ""; }else{ $Name = NULL; echo "Please fill out your Country.<br />"; echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?main_page=contact_us_1\">"; exit; } */ if (preg_match ("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i", $Email)) { mail($toaddress,$subject,$headers,$message); //clear the variables $Name=''; $Email=''; echo ""; } else { echo nl2br ("Please enter correct email.\n"); echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?main_page=contact_us_1\">"; } $formsend = mail("$recipient", "$subject", "$forminfo", "From: $email\r\nReply-to:$email"); ?> <!-- end PHP easy-form --> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Make a Donation</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="refresh" content="5; URL=index.php?main_page=page_2"> <style type="text/css"> <!-- .style1 { font-size: 24px; font-weight: bold; } body { background-color: #ade4b0; } --> </style> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <td> <p align="left" class="style1">Thank you. You submission has been complete.Redirecting...</p> </tr> </table> </td> </body> </html> There is a lot of extra code in here that I have commented out because I have been testing a lot of things. But I am "OK" with the form going to another page to validate and want I want it to do is check for empty fields and report an error if there are any. The way I have it now it does that but if I do not put an exit; at the end of the else on any of them it will report an error and go ahead and send the email with a blank form. It works best if i put exit; on the email because that is the last field so it works OK but if someone chooses to put there email and nothing else the form will go ahead and send. I see the validation that you have setup on this form seems to be javascript and a box comes up notifying the user that a field is missing information. I do not mean to be picky but I would rather it either be displayed on the same page in words instead of a pop up box or the way I have it setup now where it needs to go to another page to validate. I am just needing the required fields to work just a "little" better. Out of curiousity why do you have it with so many different php pages? Is it easier that way or what. Again thanks for all the help please don't think I do not appreciate the help I do not want to be "one of those guys" who gives you a hard time I am just trying to make it the best I can. One more point is if you go to the link I have put on the page. I love the way the form is positioned if I can keep the positioning of the form like this that would be great as well.
  11. Hello everyone I could use some help. I have a form which I have on a site to you can see and I like it very much. However the validation I have I don't really like. I have it setup to check if certain fields are blank and if I hit submit it will check the first field to see if it is blank if it is it will take me to an error page. However if it is not it will go to the next field and check. However what I would like is it to check the whole form and display all the errors at once. I would also prefer to have the errors displayed on the page without having to refresh. I have spent many hours on this and just trying to perfect it. The way I have it set up it works and even sends the email just the way I like I just need some help with the validation. Please if anyone can help I would be extremely thankful. Here is some detailed information about what I am working with...I would also like to be able to have the sender be the name that is entered by the user. I have tried changing the headers and so forth but doesn't seem to work. My PHP looks like this <? $Name = $_POST["Name"]; $Address = $_POST["Address"]; $Address2 = $_POST["Address2"]; $City = $_POST["City"]; $State = $_POST["State"]; $Country = $_POST["Country"]; $Zip = $_POST["Zip"]; $Phone = $_POST["Phone"]; $Email = $_POST["Email"]; $today = date("M d, Y"); $recipient = "you@yourdomain.com"; $subject = "TEST SUBJECt"; $headers = 'From: <webmaster@example.com>' . "\r\n"; $forminfo = "Name: $Name\n Address: $Address\n Address2: $Address2\n City: $City\n State: $State\n Country: $Country\n Zip: $Zip\n Phone: $Phone\n Email: $Email\n Form Submitted: $today\n\n"; if (!empty($_POST['Name'])){ $msg = ""; }else{ $Name = NULL; echo "Please fill out your first name.<br />"; echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?main_page=contact_us_1\">"; exit; } if (!empty($_POST['Address'])){ $msg = ""; }else{ $Name = NULL; echo "Please fill out your Street Name.<br />"; echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?main_page=contact_us_1\">"; exit; } if (!empty($_POST['City'])){ $msg = ""; }else{ $Name = NULL; echo "Please fill out your City.<br />"; echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?main_page=contact_us_1\">"; exit; } if (!empty($_POST['State'])){ $msg = ""; }else{ $Name = NULL; echo "Please fill out your State.<br />"; echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?main_page=contact_us_1\">"; exit; } if (!empty($_POST['Country'])){ $msg = ""; }else{ $Name = NULL; echo "Please fill out your Country.<br />"; echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?main_page=contact_us_1\">"; exit; } /* if (!empty($_POST['LastName'])){ $msg = ""; }else{ $LastName = NULL; echo "Please fill out your Last name.<br />"; echo "<meta http-equiv=\"refresh\" content=\"2;URL=form.html\">"; exit; } */ if (preg_match ("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i", $Email)) { mail($toaddress,$subject,$headers,$message); //clear the variables $Name=''; $Email=''; echo ""; } else { echo nl2br ("Please enter correct email.\n"); echo "<meta http-equiv=\"refresh\" content=\"2;URL=index.php?main_page=contact_us_1\">"; exit; } $formsend = mail("$recipient", "$subject", "$forminfo", "From: $email\r\nReply-to:$email"); ?> <!-- end PHP easy-form --> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Make a Donation</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="refresh" content="5; URL=index.php?main_page=contact_us_1"> <style type="text/css"> <!-- .style1 { font-size: 24px; font-weight: bold; } body { background-color: #ade4b0; } --> </style> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <td> <p align="left" class="style1">Thank you. You submission has been complete.Redirecting...</p> </tr> </table> </td> </body> </html> My HTML looks like this <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Untitled Form</title> <link rel="stylesheet" type="text/css" href="view.css" media="all"> <script type="text/javascript" src="view.js"></script> </head> <body id="main_body" > <br /> <br /> <div id="form_container"> <form id="form_14512" class="appnitro" method="post" action="myform.php"> <div class="form_description"> <h2>Request A Brochure</h2> </div> <ul > <li id="li_1" > <label class="description" for="Name">* Name </label> <div> <input id="Name" name="Name" class="element text medium" type="text" maxlength="255" value=""/> </div><p class="guidelines" id="guide_1"><small>Enter your name</small></p> </li> <li id="li_2" > <label class="description" for="element_2">* Mailing Address </label> <div><strong> <input id="Address" name="Address" class="element text large" value="" type="text"> <label for="Address">* Street Address</label> </strong></div> <div> <input id="Address2" name="Address2" class="element text large" value="" type="text"> <label for="Address2">Address Line 2</label> </div> <div class="left"><strong> <input id="City" name="City" class="element text medium" value="" type="text"> <label for="City">* City</label> </strong></div> <div class="right"><strong> <input id="State" name="State" class="element text medium" value="" type="text"> <label for="State">* State / Province / Region</label> </strong></div> <div class="left"><strong> <input id="Zip" name="Zip" class="element text medium" maxlength="15" value="" type="text"> <label for="Zip">* Postal / Zip Code</label> </strong></div> <div class="right"><strong> <select class="element select medium" id="Country" name="Country"> <option value="" selected="selected"></option> <option value="Afghanistan" >Afghanistan</option> <option value="Albania" >Albania</option> <option value="Algeria" >Algeria</option> <option value="Andorra" >Andorra</option> <option value="Antigua and Barbuda" >Antigua and Barbuda</option> <option value="Argentina" >Argentina</option> <option value="Armenia" >Armenia</option> <option value="Australia" >Australia</option> <option value="Austria" >Austria</option> <option value="Azerbaijan" >Azerbaijan</option> <option value="Bahamas" >Bahamas</option> <option value="Bahrain" >Bahrain</option> <option value="Bangladesh" >Bangladesh</option> <option value="Barbados" >Barbados</option> <option value="Belarus" >Belarus</option> <option value="Belgium" >Belgium</option> <option value="Belize" >Belize</option> <option value="Benin" >Benin</option> <option value="Bhutan" >Bhutan</option> <option value="Bolivia" >Bolivia</option> <option value="Bosnia and Herzegovina" >Bosnia and Herzegovina</option> <option value="Botswana" >Botswana</option> <option value="Brazil" >Brazil</option> <option value="Brunei" >Brunei</option> <option value="Bulgaria" >Bulgaria</option> <option value="Burkina Faso" >Burkina Faso</option> <option value="Burundi" >Burundi</option> <option value="Cambodia" >Cambodia</option> <option value="Cameroon" >Cameroon</option> <option value="Canada" >Canada</option> <option value="Cape Verde" >Cape Verde</option> <option value="Central African Republic" >Central African Republic</option> <option value="Chad" >Chad</option> <option value="Chile" >Chile</option> <option value="China" >China</option> <option value="Colombia" >Colombia</option> <option value="Comoros" >Comoros</option> <option value="Congo" >Congo</option> <option value="Costa Rica" >Costa Rica</option> <option value="Côte d'Ivoire" >Côte d'Ivoire</option> <option value="Croatia" >Croatia</option> <option value="Cuba" >Cuba</option> <option value="Cyprus" >Cyprus</option> <option value="Czech Republic" >Czech Republic</option> <option value="Denmark" >Denmark</option> <option value="Djibouti" >Djibouti</option> <option value="Dominica" >Dominica</option> <option value="Dominican Republic" >Dominican Republic</option> <option value="East Timor" >East Timor</option> <option value="Ecuador" >Ecuador</option> <option value="Egypt" >Egypt</option> <option value="El Salvador" >El Salvador</option> <option value="Equatorial Guinea" >Equatorial Guinea</option> <option value="Eritrea" >Eritrea</option> <option value="Estonia" >Estonia</option> <option value="Ethiopia" >Ethiopia</option> <option value="Fiji" >Fiji</option> <option value="Finland" >Finland</option> <option value="France" >France</option> <option value="Gabon" >Gabon</option> <option value="Gambia" >Gambia</option> <option value="Georgia" >Georgia</option> <option value="Germany" >Germany</option> <option value="Ghana" >Ghana</option> <option value="Greece" >Greece</option> <option value="Grenada" >Grenada</option> <option value="Guatemala" >Guatemala</option> <option value="Guinea" >Guinea</option> <option value="Guinea-Bissau" >Guinea-Bissau</option> <option value="Guyana" >Guyana</option> <option value="Haiti" >Haiti</option> <option value="Honduras" >Honduras</option> <option value="Hong Kong" >Hong Kong</option> <option value="Hungary" >Hungary</option> <option value="Iceland" >Iceland</option> <option value="India" >India</option> <option value="Indonesia" >Indonesia</option> <option value="Iran" >Iran</option> <option value="Iraq" >Iraq</option> <option value="Ireland" >Ireland</option> <option value="Israel" >Israel</option> <option value="Italy" >Italy</option> <option value="Jamaica" >Jamaica</option> <option value="Japan" >Japan</option> <option value="Jordan" >Jordan</option> <option value="Kazakhstan" >Kazakhstan</option> <option value="Kenya" >Kenya</option> <option value="Kiribati" >Kiribati</option> <option value="North Korea" >North Korea</option> <option value="South Korea" >South Korea</option> <option value="Kuwait" >Kuwait</option> <option value="Kyrgyzstan" >Kyrgyzstan</option> <option value="Laos" >Laos</option> <option value="Latvia" >Latvia</option> <option value="Lebanon" >Lebanon</option> <option value="Lesotho" >Lesotho</option> <option value="Liberia" >Liberia</option> <option value="Libya" >Libya</option> <option value="Liechtenstein" >Liechtenstein</option> <option value="Lithuania" >Lithuania</option> <option value="Luxembourg" >Luxembourg</option> <option value="Macedonia" >Macedonia</option> <option value="Madagascar" >Madagascar</option> <option value="Malawi" >Malawi</option> <option value="Malaysia" >Malaysia</option> <option value="Maldives" >Maldives</option> <option value="Mali" >Mali</option> <option value="Malta" >Malta</option> <option value="Marshall Islands" >Marshall Islands</option> <option value="Mauritania" >Mauritania</option> <option value="Mauritius" >Mauritius</option> <option value="Mexico" >Mexico</option> <option value="Micronesia" >Micronesia</option> <option value="Moldova" >Moldova</option> <option value="Monaco" >Monaco</option> <option value="Mongolia" >Mongolia</option> <option value="Montenegro" >Montenegro</option> <option value="Morocco" >Morocco</option> <option value="Mozambique" >Mozambique</option> <option value="Myanmar" >Myanmar</option> <option value="Namibia" >Namibia</option> <option value="Nauru" >Nauru</option> <option value="Nepal" >Nepal</option> <option value="Netherlands" >Netherlands</option> <option value="New Zealand" >New Zealand</option> <option value="Nicaragua" >Nicaragua</option> <option value="Niger" >Niger</option> <option value="Nigeria" >Nigeria</option> <option value="Norway" >Norway</option> <option value="Oman" >Oman</option> <option value="Pakistan" >Pakistan</option> <option value="Palau" >Palau</option> <option value="Panama" >Panama</option> <option value="Papua New Guinea" >Papua New Guinea</option> <option value="Paraguay" >Paraguay</option> <option value="Peru" >Peru</option> <option value="Philippines" >Philippines</option> <option value="Poland" >Poland</option> <option value="Portugal" >Portugal</option> <option value="Puerto Rico" >Puerto Rico</option> <option value="Qatar" >Qatar</option> <option value="Romania" >Romania</option> <option value="Russia" >Russia</option> <option value="Rwanda" >Rwanda</option> <option value="Saint Kitts and Nevis" >Saint Kitts and Nevis</option> <option value="Saint Lucia" >Saint Lucia</option> <option value="Saint Vincent and the Grenadines" >Saint Vincent and the Grenadines</option> <option value="Samoa" >Samoa</option> <option value="San Marino" >San Marino</option> <option value="Sao Tome and Principe" >Sao Tome and Principe</option> <option value="Saudi Arabia" >Saudi Arabia</option> <option value="Senegal" >Senegal</option> <option value="Serbia and Montenegro" >Serbia and Montenegro</option> <option value="Seychelles" >Seychelles</option> <option value="Sierra Leone" >Sierra Leone</option> <option value="Singapore" >Singapore</option> <option value="Slovakia" >Slovakia</option> <option value="Slovenia" >Slovenia</option> <option value="Solomon Islands" >Solomon Islands</option> <option value="Somalia" >Somalia</option> <option value="South Africa" >South Africa</option> <option value="Spain" >Spain</option> <option value="Sri Lanka" >Sri Lanka</option> <option value="Sudan" >Sudan</option> <option value="Suriname" >Suriname</option> <option value="Swaziland" >Swaziland</option> <option value="Sweden" >Sweden</option> <option value="Switzerland" >Switzerland</option> <option value="Syria" >Syria</option> <option value="Taiwan" >Taiwan</option> <option value="Tajikistan" >Tajikistan</option> <option value="Tanzania" >Tanzania</option> <option value="Thailand" >Thailand</option> <option value="Togo" >Togo</option> <option value="Tonga" >Tonga</option> <option value="Trinidad and Tobago" >Trinidad and Tobago</option> <option value="Tunisia" >Tunisia</option> <option value="Turkey" >Turkey</option> <option value="Turkmenistan" >Turkmenistan</option> <option value="Tuvalu" >Tuvalu</option> <option value="Uganda" >Uganda</option> <option value="Ukraine" >Ukraine</option> <option value="United Arab Emirates" >United Arab Emirates</option> <option value="United Kingdom" >United Kingdom</option> <option value="United States" >United States</option> <option value="Uruguay" >Uruguay</option> <option value="Uzbekistan" >Uzbekistan</option> <option value="Vanuatu" >Vanuatu</option> <option value="Vatican City" >Vatican City</option> <option value="Venezuela" >Venezuela</option> <option value="Vietnam" >Vietnam</option> <option value="Yemen" >Yemen</option> <option value="Zambia" >Zambia</option> <option value="Zimbabwe" >Zimbabwe</option> </select> <label for="Country">* Country</label> </strong></div> <p class="guidelines" id="guide_2"><small>Enter your mailing address</small></p> </li> <li id="li_3" > <label class="description" for="Phone">Phone Number </label> <div> <input id="Phone" name="Phone" class="element text medium" type="text" maxlength="255" value=""/> </div><p class="guidelines" id="guide_3"><small>Enter your phone number</small></p> </li> <li id="li_4" > <label class="description" for="Email">* Email </label> <div> <input id="Email" name="Email" class="element text medium" type="text" maxlength="255" value=""/> </div><p class="guidelines" id="guide_4"><small>Enter your email address</small></p> </li> <li class="buttons"> <input type="hidden" name="form_id" value="14512" /> <input value="Submit form" type="submit" /> </li> </ul> </form> <div id="footer"></div> </div> </body> </html> You can see the form in working order on the site located here http://www.+stxm+illing.com+/index.+...=conta+ct_us_1 PLEASE TAKE THE '+' OUT OF THE URL IN ORDER FOR IT TO WORK. Any feedback is greatly appreciated!!
  12. I have a site that i am pretty much done with. There are bits and pieces that i need to add but that can happen later. I need the contact form done so i can post it on my actual website and go from there. I can not seem to get the php form to work correctly. Some times it emails me and some times it doesn't. Sounds strange i know. I know it is something i am doing wrong and i admit it i am a huge newbie to flash and php. I can sometimes get the form to email me but it is only one line of text. Like the comments that i type it work. However the name, subject and the other stuff doesn't show up. I have researched so many things and used some many examples and i am tired. Is there someone out there willing to lend a helping hand. My site that the contact for is on is. http://wpc-consulting.com/indextest.htm. It is on the contact page once you get to the main site. I am going to upload my php file which i know is wrong because i tried editing it and my flash file. If anyone could help me with the php code i would be sooo grateful. I am to get this form to email me all the information that is entered by the user. I would also like an email validation. [attachment deleted by admin]
  13. This form that i really like is off a website however i can customize it. I am interested in getting it to work though. Anyways i uploaded the actionscript code to the flash document. However i don't have the php. I am having trouble trying to figure it out. I have used lots of examples however cant seem to get any to work. [attachment deleted by admin]
  14. Thanks for the reply but i was serious when i said i am a php newbie. I am also fairly new at flash. I have only been working with flash for about a month. I am not exactly sure why lots of this information is coming from the flash form when i thought it was all in the php form. For example on the flash form in my opinion if you want to clear the form that is all actionscript on the clear button in flash however if you want to submit it to email. The only actionscript on the submit button pretty much is to load the variable email.php or whatever. Then that tells you where to send it and how and all that. I could be wrong but i have been researching different...LOTS of different contacts and i am just sooooo confused on the php. I see the strings and stuff but i am just want the darn thing to work with flash.
  15. I am trying to have someone type in their info along with a message and send it in an email. However most of the time it doesn't seem to go to email the majority of the time. What do you mean $email; //get from flash? My email address is actually in flash. I thought the email address was in the php code? I am sorry i am very new and i am aware that there are many ways to do a certain code which i think is why i am getting pretty confused.
×
×
  • 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.