Jump to content

fastsol

Moderators
  • Posts

    827
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by fastsol

  1. I'm doing more "assuming" cause you still haven't provided any clue as to what your code looks like. But it kind of looks like you're wanting to change the value of $quantity based on a input field being posted. $quantity = (int)$_POST['quantity']; // (int) is used for security to type cast the value to an integer. Could also be $_GET['quantity'] but more likely $_POST. But that also assumes that your inputs name is quantity.
  2. Can't give you a exact code since you didn't provide us with any of your code to compare with, but here is a basic idea. PHP is very good at math, so just use normal mathematic operators and maybe a function depending how you want the output to look. $price_per_item = 1.2; $quantity = 10; $total = $price_per_item * $quantity; echo $total; $formatted_total = number_format($total, 2); // formats the number to have 2 decimal places. echo $formatted_total; Beyond that you'll have to show us your code that deals with those specific areas.
  3. Ahh, I did find something that I forgot to add to the link to make it not appear until after the page fully loaded. If the link was clicked before the page finished loading the token var had not been set in php yet, so when trying to access the token on the dlupd.php it wasn't able to match that token and triggering the unavailable message. That link was I think the only one I had forgotten when coding it a while back. I guess thanks for catching that, who knows how many downloads I have missed cause of that
  4. You're not accessing the data attribute in the input field, you're only accessing the value attribute. But even that is not working cause you are trying to get a value form a element with id of ss_id_other which doesn't exist. Try this $.post('selectedBenefit.php',{ss_num: $("input[name='arr_bnft_records']").data('ss_id_other')});
  5. Can you be more specific as to which link you are referring to? I test them often and all seem to be working for me. Was it giving you a pop up type message saying the file is unavailable?
  6. You could maybe do something like email piping. I have never actually done it, but basically any email sent to a specified address will be sent to a php script and you can then process the contents as you want. I have not watched these videos but maybe see if they address your issue appropriately https://www.youtube.com/results?search_query=php+email+piping
  7. https://www.youtube.com/watch?v=Upc_fwaiosg https://www.youtube.com/watch?v=FCDr0okbJaM
  8. Your best bet would be to use a CMS (content management system). There are several kinds out there, most are free, but most are not super easy to edit to get the site to look the way you want without some decent knowledge of php/htlm/css. I have a personally made CMS that I distribute at http://amecms.com/download . I would not say that mine is super easy to integrate either but it's easier than most in my opinion. It also has a number of the features already built in that you are asking for and currently use on your site now. It has a articles plugin for the news feature and a gallery plugin for your current gallery that you can download too and install at the same time. Since your site is already using divs and css, this shouldn't be too difficult and will allow you to have all the features you want and more.
  9. Why not just apply the sames logic to the container as you have to retain the selected option. if($values['store_id'] == "OTH") Just put that (and the proper other info/syntax) in the div tag to change it's display property.
  10. There are a number of things wrong with your code, to many to list honestly! I reworked the code for you so you can see the right way to do this. I did not take in to account any security, so you seriously should expand on that before using this on a live site. I got rid of the EOD stuff, I really don't konw why people use that, at least I never have and I don't like the syntax it uses. Since I didn't take the time to remake your actualy form, I can't say this is perfect, but it doesn't throw any syntax errors when loaded. if (isset($_POST["submit"])) { /* Email Variables */ $emailSubject = 'Contact Form'; $webMaster = '[email protected]'; $webMaster = '[email protected]'; //$webMaster = '[email protected]'; /* Data Variables */ $name = $_POST['name']; $company = $_POST['company']; $phone = $_POST['phone']; $altphone = $_POST['altphone']; $mail = $_POST['mail']; $city = $_POST['city']; $emai = $_POST['emai']; $list = $_POST["list"]; $volunteer = $_POST["volunteer"]; $opportunities = $_POST["opportunities"]; $cause = $_POST["cause"]; $contribute = $_POST['contribute']; $body = " <br><br> Name(s): $name<br> Company if Applicable: $company<br> Phone: $phone<br> Alternate Phone: $altphone<br> Street Address: $mail<br> City, State, Zip Code: $city<br> Email: $emai<br> Would you like to be part of our mailing list? $list<br> Are you interested in volunteering for upcoming events? $volunteer<br> Are you interested in becoming a sponsor by receiving opportunities to advertise through us? $opportunities<br> Would you like to join our efforts by offering your services or products to further our cause? $cause<br> If so, in what ways would you like to contribute? $contribute<br>"; $from = "From: [email protected]\r\n"; $from .= "Reply-To: ".$emai."\r\n"; $from .= "Content-type: text/html\r\n"; mail($webMaster, $emailSubject, $body, $from); /* Results rendered as HTML */ header("Location: http://www.brianewagnerfund.org/thankyou.html"); } You truly should take a look and follow the tutorial link I previously posted so you can integrate the security it needs.
  11. The background works fine for me with your full css included. The problem that I see is that if you are putting all the css in a separate file (like you should), you CANNOT have the <style> tags in that file. The code you posted has those tags in it.
  12. I have attached the zip file here Screen Shots sql.zip
  13. Have you tried adding something like this $title = preg_replace('/[^'.$this->cSeprator.'-#%&\s]+/', '', $title); I am no regex person so that may be totally wrong or it might be close.
  14. So I built a tool for my cms a while back and have decided to share it. The only 2 things that I know of that are similar in nature is phpmyadmin or sql buddy. Now my tool is not nearly as in depth as either of those but what it lets you do is run any query string right from the webpage. But the cool thing that it has over phpmyadmin and sql buddy is that it has buttons for many of the common commands and a ajax select to get the available column names for the selected table. So now you don't have to try and remember what table had what column and "how did I spell that column again". I use this to test sql strings for syntax and to quickly see if it returns the results I expect without having to edit the code and then save, upload or hit refresh or whatever. Since all the the stuff is done via ajax, it's all quickly displayed and you can change the query immediately and hit the Run Query button again. I just thought that this could be helpful and useful for others. You can download it here http://amecms.com/article/Test-SQL-Strings-Quickly-and-Easily
  15. Well I am far from knowledgeable with how a server really works, so touche. I guess I can't say that it's a perfect solution on my page either then, all I can test is me going to the script from my laptop and having it say Invalid Request. I don't know a single thing about a proxy. As far as the path stuff goes, I just remembered that I wasn't trying to run it outside the root but rather a directory up or 2 from the root. It gave me tons of (I think) include and require path issues cause CRON runs from a different path or something than the actual root, so it couldn't locate numerous files. Now MAYBE that's something on how my files are coded but I found many other people with the same issue. I'm always up for learning a better way
  16. I found a couple fundamental flaws in what I recently posted. First was if it reutrned a message of needing a fields filled in, it would not retain the text in the input fields. It was only a flaw cause I tried to modify how I normally do it and found out why I do it hte way I do, so I changed it back. Second, I found a way to validate if an radio button was not in the post array for the requireFields() to use. Third, removed a if() for the gender checking now that the requiredFields() will handle it appropriately. Here is an updated version. <?php require_once('recaptchalib.php'); $privatekey = "6LdK8_YSAAAAAJYPJduOpxhsL4Cy86NgwpCSJCod"; $publickey = "6LdK8_YSAAAAACMvxVRzJ7ZNqjQ9nT_dU6fEZdHx"; // you got this from the signup page function validCaptcha($privatekey) { $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if($resp->is_valid === FALSE) { return $errors[] = "The Captcha did not pass validation. Please try again."; } else{ return TRUE; } } function cleanTextarea($p) { $post = htmlentities(trim($p)); return $post; } function requiredFields($posted, $req) { $message = 'Please fill in all required fields'; // This is mostly to verify if a required radio button was not selected since if it wasn't it won't be in the $_POST array. $all_there = array_diff($req, array_keys($posted)); // Then set an error if the above array isn't empty if(!empty($all_there)) { return $errors[] = $message; } else { foreach($posted as $key => $val) { $val = cleanTextarea($val); if(in_array($key, $req) && empty($val)) { $bad = TRUE; return $errors[] = $message; // If a value was empty we add an error to the $GLOBALS['errors'] array so we can display it later to the user. break 1; } } if(!isset($bad)){return TRUE;} // If no errors, return true; } } // Display form errors. // $issue needs to be an array of the errors. // The ul uses a default class of form-errors and you can designate a second class as the second param in the function call. function formErrors($issue, $sec_class = NULL) { $sec_class = (!empty($sec_class)) ? $sec_class : ''; echo '<ul class="form-errors '.$sec_class.'">'; foreach($issue as $i) {echo "<li>$i</li>";} echo "</ul>"; } // Sets the form completion display // $phrase should be a string that you want displayed to the user if the form passes all validation. // Defaults to displaying a h1 tag but you may designate a different element as the second param in the function call. function formComplete($phrase, $element = NULL) { $element = ($element !== NULL) ? $element : 'h1'; echo '<'.$element.' class="form-complete">'.$phrase.'</'.$element.'>'; } $country_options= array("select","Afghanistan", "Ã…Land Islands", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua And Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia And Herzegovina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo, The Democratic Republic Of The", "Cook Islands", "Costa Rica", "Cote D'Ivoire", "Croatia", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "French Guiana", "French Polynesia", "French Southern Territories", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guernsey", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard Island And Mcdonald Islands", "Holy See (Vatican City State)", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran, Islamic Republic Of", "Iraq", "Ireland", "Isle Of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, Democratic People'S Republic Of", "Korea, Republic Of", "Kuwait", "Kyrgyzstan", "Lao People'S Democratic Republic", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libyan Arab Jamahiriya", "Liechtenstein", "Lithuania", "Luxembourg", "Macao", "Macedonia, The Former Yugoslav Republic Of", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia, Federated States Of", "Moldova, Republic Of", "Monaco", "Mongolia", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Palestinian Territory, Occupied", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Pitcairn", "Poland", "Portugal", "Puerto Rico", "Qatar", "Reunion", "Romania", "Russian Federation", "Rwanda", "Saint Helena", "Saint Kitts And Nevis", "Saint Lucia", "Saint Pierre And Miquelon", "Saint Vincent And The Grenadines", "Samoa", "San Marino", "Sao Tome And Principe", "Saudi Arabia", "Senegal", "Serbia And Montenegro", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Georgia And The South Sandwich Islands", "Spain", "Sri Lanka", "Sudan", "Suriname", "Svalbard And Jan Mayen", "Swaziland", "Sweden", "Switzerland", "Syrian Arab Republic", "Taiwan, Province Of China", "Tajikistan", "Tanzania, United Republic Of", "Thailand", "Timor-Leste", "Togo", "Tokelau", "Tonga", "Trinidad And Tobago", "Tunisia", "Turkey", "Turkmenistan", "Turks And Caicos Islands", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela", "Viet Nam", "Virgin Islands, British", "Virgin Islands, U.S.", "Wallis And Futuna", "Western Sahara", "Yemen", "Zambia", "Zimbabwe" ); if (isset($_POST['submit'])) { // Moved all these vars above the if() below so they will retain if some required fields were not filled in. $name = isset($_POST['name']) ? cleanTextarea($_POST['name']) : ''; $email = isset($_POST['email']) ? cleanTextarea($_POST['email']) : ''; $phone = isset($_POST['phone']) ? cleanTextarea($_POST['phone']) : ''; $country = (isset($_POST['country']) && $_POST['country'] != 'select') ? $_POST['country'] : ''; $comment = isset($_POST['comment']) ? cleanTextarea($_POST['comment']) : ''; $gender = isset($_POST['gender']) ? cleanTextarea($_POST['gender']) : ''; $required = array('name', 'email', 'country', 'gender'); $check_required = requiredFields($_POST, $required); if($check_required !== TRUE){ $errors[] = $check_required; } else { $gender_options = array('male', 'female'); $to = "[email protected]"; $subject = "New contact form submission"; $message =" A visitor of WIKIGETS has submited a form online\n\nName: $name\n\nEmail: $email\n\nPhone: $phone \n\nCountry: $country \n\nGender: $gender\n\nComment: $comment"; // check if name only contains letters and whitespace if (!preg_match("/^[a-zA-Z ]*$/",$name)) { $errors[] = "Only letters and spaces allowed in your name"; } // check if e-mail address syntax is valid if (filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE) { $errors[] = "Invalid email format"; } if(!preg_replace('/\D/', '', $phone)) { $errors[] = 'Your phone number is not in the proper format.'; } if(!in_array($gender, $gender_options)) // Removed a if() here that is no longer need with the modified requiredFields() above. { $errors[] = 'That is not a gender selection.'; } if(!in_array($country, $country_options)) { $errors[] = 'Please select your country.'; } $check = validCaptcha($privatekey); if($check !== TRUE) { $errors[] = $check; } } if(!empty($errors)){} else { $headers = 'MIME-Version: 1.0' . "rn"; $headers .= 'Content-Type: text/plain; charset=iso-8859-1' . "rn"; if(mail($to, $subject, $message, $headers) === TRUE) { $success = TRUE; $name = $email = $phone = $gender = $country = $comment = ''; } else { $success = FALSE; } } } ?> <!DOCTYPE HTML> <html> <head> <title>Contact Us</title> <style> .error {color: #FF0000;} .success {color:#360; background-color:#FF0;} .fail {color:#F00; background-color:#FFF;} .form-errors li { color: #FFFFFF; border: 2px solid #FF0000; border-radius: 4px; -webkit-border-radius: 4px; -moz-border-radius: 4px; padding: 4px; margin: 4px; background-color: #FF5050; } .form-complete { color: #FFFFFF; border: 2px solid #009900; border-radius: 4px; -webkit-border-radius: 4px; -moz-border-radius: 4px; padding: 4px; margin: 4px; background-color: #33CC33; font-size: 14px; } </style> </head> <body> <h2>CONTACT US</h2> <p> <?php if(!empty($errors)) { formErrors($errors); } elseif(isset($success) && $success === TRUE) { formComplete('You mesage has been sent. We will get back to you shortly.'); } elseif(isset($success) && $success === FALSE) { formErrors(array('Your email was unable to be sent. Please try again.')); } ?> </p> <form method="post" action=""> <p>Name: <input type="text" name="name" value="<?php echo isset($name) ? $name : ''; ?>"> <br><br> E-mail: <input type="text" name="email" value="<?php echo isset($email) ? $email : '';?>"> </p> <p>Phone Number:<input type="text" name="phone" value="<?php echo isset($phone) ? $phone : '';?>"> <br> <br> Country: <?php $item = 'select'; echo '<select name="country">'; foreach($country_options as $c) { $sel=''; // Set $sel to empty initially $tag = 'selected="selected"'; if(isset($_POST['country']) && $_POST['country'] == $c) // Here we check if the form has been posted so an error isn't thrown and then check it's value against $c { $sel = $tag; } elseif(!isset($_POST['country']) && $item == $c) // So that the $item doesn't override the posted value we need to check to make sure the form has NOT been submitted also in the { $sel = $tag; } echo '<option value="'.$c.'" '.$sel.'>'.$c.'</option>'; } echo '</select>'; ?> <span class="error">*<?php echo (isset($country1)) ? $country1 : '';?></span> <br><br> Gender: <input type="radio" name="gender" <?php if (isset($gender) && $gender=="female") echo "checked";?> value="female">Female <input type="radio" name="gender" <?php if (isset($gender) && $gender=="male") echo "checked";?> value="male">Male <br><br> Comment: <textarea name="comment" rows="5" cols="40"><?php echo isset($comment) ? $comment : '';?></textarea> <br> <?php echo recaptcha_get_html($publickey); ?> <br> <input type="submit" name="submit" value="Submit"> </p> </form> </body> </html>
  17. That's probably true if you're not seeing basic undefined errors. I use E_ALL but have the upper levels like E_STRICT and something else turned off.
  18. The one problem that I have run into trying that method is that your paths for any included files become difficult to figure out. Plus if you're using a framework to gather a bunch of files that have critical parts being used in the cron script it's very hard to modify all those files and you really don't want to cause they are core files to the framework. So what I use is this at the very top of the cron script. This way no outside IP can run the script contents below this line, it'll just return a Invalid Request to whom ever is trying to access it. if($_SERVER["REMOTE_ADDR"] != $_SERVER["SERVER_ADDR"]) die("Invalid Request");
  19. Here is a reworked and functional code based on your original code. It does include the captcha which you seem to have removed in your more recent posts. <?php require_once('recaptchalib.php'); $privatekey = "6LdK8_YSAAAAAJYPJduOpxhsL4Cy86NgwpCSJCod"; $publickey = "6LdK8_YSAAAAACMvxVRzJ7ZNqjQ9nT_dU6fEZdHx"; // you got this from the signup page function validCaptcha($privatekey) { $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if($resp->is_valid === FALSE) { return $errors[] = "The Captcha did not pass validation. Please try again."; } else{ return TRUE; } } function cleanTextarea($p) { $post = htmlentities(trim($p)); return $post; } function requiredFields($posted, $req) { foreach($posted as $key => $val) { $val = cleanTextarea($val); if(in_array($key, $req) && empty($val)) { $bad = TRUE; return $errors[] = 'Please fill in all required fields'; // If a value was empty we add an error to the $GLOBALS['errors'] array so we can display it later to the user. break 1; } } if(!isset($bad)){return TRUE;} // If no errors, return true; } // Display form errors. // $issue needs to be an array of the errors. // The ul uses a default class of form-errors and you can designate a second class as the second param in the function call. function formErrors($issue, $sec_class = NULL) { $sec_class = (!empty($sec_class)) ? $sec_class : ''; echo '<ul class="form-errors '.$sec_class.'">'; foreach($issue as $i) {echo "<li>$i</li>";} echo "</ul>"; } // Sets the form completion display // $phrase should be a string that you want displayed to the user if the form passes all validation. // Defaults to displaying a h1 tag but you may designate a different element as the second param in the function call. function formComplete($phrase, $element = NULL) { $element = ($element !== NULL) ? $element : 'h1'; echo '<'.$element.' class="form-complete">'.$phrase.'</'.$element.'>'; } $country_options= array("select","Afghanistan", "Ã…Land Islands", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua And Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia And Herzegovina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo, The Democratic Republic Of The", "Cook Islands", "Costa Rica", "Cote D'Ivoire", "Croatia", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "French Guiana", "French Polynesia", "French Southern Territories", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guernsey", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard Island And Mcdonald Islands", "Holy See (Vatican City State)", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran, Islamic Republic Of", "Iraq", "Ireland", "Isle Of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, Democratic People'S Republic Of", "Korea, Republic Of", "Kuwait", "Kyrgyzstan", "Lao People'S Democratic Republic", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libyan Arab Jamahiriya", "Liechtenstein", "Lithuania", "Luxembourg", "Macao", "Macedonia, The Former Yugoslav Republic Of", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia, Federated States Of", "Moldova, Republic Of", "Monaco", "Mongolia", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Palestinian Territory, Occupied", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Pitcairn", "Poland", "Portugal", "Puerto Rico", "Qatar", "Reunion", "Romania", "Russian Federation", "Rwanda", "Saint Helena", "Saint Kitts And Nevis", "Saint Lucia", "Saint Pierre And Miquelon", "Saint Vincent And The Grenadines", "Samoa", "San Marino", "Sao Tome And Principe", "Saudi Arabia", "Senegal", "Serbia And Montenegro", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Georgia And The South Sandwich Islands", "Spain", "Sri Lanka", "Sudan", "Suriname", "Svalbard And Jan Mayen", "Swaziland", "Sweden", "Switzerland", "Syrian Arab Republic", "Taiwan, Province Of China", "Tajikistan", "Tanzania, United Republic Of", "Thailand", "Timor-Leste", "Togo", "Tokelau", "Tonga", "Trinidad And Tobago", "Tunisia", "Turkey", "Turkmenistan", "Turks And Caicos Islands", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela", "Viet Nam", "Virgin Islands, British", "Virgin Islands, U.S.", "Wallis And Futuna", "Western Sahara", "Yemen", "Zambia", "Zimbabwe" ); if (isset($_POST['submit'])) { $required = array('name', 'email', 'country'); $check_required = requiredFields($_POST, $required); if($check_required !== TRUE){ $errors[] = $check_required; } else { $name = isset($_POST['name']) ? cleanTextarea($_POST['name']) : ''; $email = isset($_POST['email']) ? cleanTextarea($_POST['email']) : ''; $phone = isset($_POST['phone']) ? cleanTextarea($_POST['phone']) : ''; $country = (isset($_POST['country']) && $_POST['country'] != 'select') ? $_POST['country'] : ''; $comment = isset($_POST['comment']) ? cleanTextarea($_POST['comment']) : ''; $gender = isset($_POST['gender']) ? cleanTextarea($_POST['gender']) : ''; $gender_options = array('male', 'female'); $to = "[email protected]"; $subject = "New contact form submission"; $message =" A visitor of WIKIGETS has submited a form online\n\nName: $name\n\nEmail: $email\n\nPhone: $phone \n\nCountry: $country \n\nGender: $gender\n\nComment: $comment"; // check if name only contains letters and whitespace if (!preg_match("/^[a-zA-Z ]*$/",$name)) { $errors[] = "Only letters and spaces allowed in your name"; } // check if e-mail address syntax is valid if (filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE) { $errors[] = "Invalid email format"; } if(!preg_replace('/\D/', '', $phone)) { $errors[] = 'Your phone number is not in the proper format.'; } if(empty($gender)) { $errors[] = 'Please select your gender.'; } elseif(!in_array($gender, $gender_options)) { $errors[] = 'That is not a gender selection.'; } if(!in_array($country, $country_options)) { $errors[] = 'Please select your country.'; } $check = validCaptcha($privatekey); if($check !== TRUE) { $errors[] = $check; } } if(!empty($errors)){} else { $headers = 'MIME-Version: 1.0' . "rn"; $headers .= 'Content-Type: text/plain; charset=iso-8859-1' . "rn"; if(mail($to, $subject, $message, $headers) === TRUE) { $success = TRUE; $name = $email = $phone = $gender = $country = $comment = ''; } else { $success = FALSE; } } } ?> <!DOCTYPE HTML> <html> <head> <title>Contact Us</title> <style> .error {color: #FF0000;} .success {color:#360; background-color:#FF0;} .fail {color:#F00; background-color:#FFF;} .form-errors li { color: #FFFFFF; border: 2px solid #FF0000; border-radius: 4px; -webkit-border-radius: 4px; -moz-border-radius: 4px; padding: 4px; margin: 4px; background-color: #FF5050; } .form-complete { color: #FFFFFF; border: 2px solid #009900; border-radius: 4px; -webkit-border-radius: 4px; -moz-border-radius: 4px; padding: 4px; margin: 4px; background-color: #33CC33; font-size: 14px; } </style> </head> <body> <h2>CONTACT US</h2> <p> <?php if(!empty($errors)) { formErrors($errors); } elseif(isset($success) && $success === TRUE) { formComplete('You mesage has been sent. We will get back to you shortly.'); } elseif(isset($success) && $success === FALSE) { formErrors(array('Your email was unable to be sent. Please try again.')); } ?> </p> <form method="post" action=""> <p>Name: <input type="text" name="name" value="<?php echo isset($name) ? $name : ''; ?>"> <br><br> E-mail: <input type="text" name="email" value="<?php echo isset($email) ? $email : '';?>"> </p> <p>Phone Number:<input type="text" name="phone" value="<?php echo isset($phone) ? $phone : '';?>"> <br> <br> Country: <?php $item = 'select'; echo '<select name="country">'; foreach($country_options as $c) { $sel=''; // Set $sel to empty initially $tag = 'selected="selected"'; if(isset($_POST['country']) && $_POST['country'] == $c) // Here we check if the form has been posted so an error isn't thrown and then check it's value against $c { $sel = $tag; } elseif(!isset($_POST['country']) && $item == $c) // So that the $item doesn't override the posted value we need to check to make sure the form has NOT been submitted also in the { $sel = $tag; } echo '<option value="'.$c.'" '.$sel.'>'.$c.'</option>'; } echo '</select>'; ?> <span class="error">*<?php echo (isset($country1)) ? $country1 : '';?></span> <br><br> Gender: <input type="radio" name="gender" <?php if (isset($gender) && $gender=="female") echo "checked";?> value="female">Female <input type="radio" name="gender" <?php if (isset($gender) && $gender=="male") echo "checked";?> value="male">Male <br><br> Comment: <textarea name="comment" rows="5" cols="40"><?php echo isset($comment) ? $comment : '';?></textarea> <br> <?php echo recaptcha_get_html($publickey); ?> <br> <input type="submit" name="submit" value="Submit"> </p> </form> </body> </html>
  20. That still doesn't show us much of anything. The model is triggered by javascript most likely, so we need to see that code and any ajax/php code that goes with it. If we can't see hwo this is functioning we can't really help you. All you have provided is the code that builds the image button.
  21. Well I just tried to piece this together on my server and I can tell you there are a ton of issues with the script in all sections of it. You have huge html errors, like a closing </html> in the middle of the page. You're also using the dreaded @ to supress php errors which is a totally terrible idea. Then I still can't figure out why you are even trying to do it this way rather than using a normal file input form element. The js you have isn't going to really do anything for you over the file input. Plus you can't get the real file path of the client file in the browser for security reasons, it's just not possible. I know you asy you don't want to start over but seriously you need to, this thing is a complete mess and will not work accurately in all browsers with this convoluted workaround of a standard file input. Here is a decent file upload tutorial with basic security taken into account https://www.youtube.com/watch?v=PRCobMXhnyw
  22. Ummm, wow, your current code is one of the worst jumbles of code I have seen in a long time. Maybe you should take in depth look at another tutorial I have about how to validate a form and the flow of logic it need to go through. Please take your time and follow it step by step and then slowly put in the additional input fields you need. http://amecms.com/article/How-to-validate-a-form-the-right-way
  23. Is this topic solved? You said in your other thread that you seemed to have fixed the issue? Please confirm if you still need help.
  24. That is not enough code for any of us to determine your problem and the code provided doesn't even have anything to do with the pop-up process or how it's being passed the info it needs to get the relevant info from the db.
×
×
  • 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.