Jump to content

Search the Community

Showing results for tags 'validation'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

  1. Hi All, Would like to ask whether can the drop down list in html can be control by Jquery with this condition? Each question can only rate for 3 times, the following drop box for that question should disable and not allow to make any rating. here is my HTML code: <div> <span id="questionnaire-question">Q1)&nbspPlease QuestionA</span> <table> <tr style="width: 365px;"> <td><label>A1</label></td> <td> <select name="ranking[13]" class="02A" group="02A"> <option value="" >Please Rank</option> <option>1</option> <option>2</option> <option>3</option> </select> </td> </tr> <tr style="width: 365px;"> <td><label>A2</label></td> <td> <select name="ranking[14]" class="02A" group="02A"> <option value="" >Please Rank</option> <option>1</option> <option>2</option> <option>3</option> </select> </td> </tr> <tr style="width: 365px;"> <td><label>A3</label></td> <td> <select name="ranking[15]" class="02A" group="02A"> <option value="" >Please Rank</option> <option>1</option> <option>2</option> <option>3</option> </select> </td> </tr> <tr style="width: 365px;"> <td><label>A4</label></td> <td> <select name="ranking[16]" class="02A" group="02A"> <option value="" >Please Rank</option> <option>1</option> <option>2</option> <option>3</option> </select> </td> </tr> </table> </div> <div> <span id="questionnaire-question">Q2)&nbspPlease QuestionB</span> <table> <tr style="width: 365px;"> <td><label>B1</label></td> <td> <select name="ranking[21]" class="03A" group="03A"> <option value="" >Please Rank</option> <option>1</option> <option>2</option> <option>3</option> </select> </td> </tr> <tr style="width: 365px;"> <td><label>B2</label></td> <td> <select name="ranking[22]" class="03A" group="03A"> <option value="" >Please Rank</option> <option>1</option> <option>2</option> <option>3</option> </select> </td> </tr> <tr style="width: 365px;"> <td><label>B3</label></td> <td> <select name="ranking[23]" class="03A" group="03A"> <option value="" >Please Rank</option> <option>1</option> <option>2</option> <option>3</option> </select> </td> </tr> <tr style="width: 365px;"> <td><label>B4</label></td> <td> <select name="ranking[28]" class="03A" group="03A"> <option value="" >Please Rank</option> <option>1</option> <option>2</option> <option>3</option> </select> </td> </tr> </table> </div> Thank You.
  2. I need you're help with jquery form validation. I have been using jguery form validation but when I have included ckeditor on the page validation stopped working. I can't figure out why. I'm not very good with javascript so it's hard for me to figure out what is blocking it. Html form I'm using is: <form action="save_costs.php" method="POST" role="form" id="form2"> <div class="row"> <div class="col-md-12"> <div class="errorHandler alert alert-danger no-display"> <i class="fa fa-times-sign"></i> You have some form errors. Please check below. </div> <div class="successHandler alert alert-success no-display"> <i class="fa fa-ok"></i> Your form validation is successful! </div> </div> <div class="col-md-6"> <div class="form-group"> <label class="control-label"> <?php if ($_SESSION['language'] == "English") { echo "Name"; } else if ($_SESSION['language'] == "Croatian") { echo "Naziv"; } ?> <span class="symbol required"></span> </label> <input type="text" placeholder="Insert name" class="form-control" id="name" name="name" /> </div> <div class="form-group"> <label class="control-label"> <?php if ($_SESSION['language'] == "English") { echo "Description"; } else if ($_SESSION['language'] == "Croatian") { echo "Opis"; } ?> <span class="symbol required"></span> </label> <input type="text" placeholder="Insert description" class="form-control" id="description" name="description" /> </div> </div> <div class="col-md-6"> <div class="row"> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="form-group"> <label class="control-label"> <?php if ($_SESSION['language'] == "English") { echo "Comments"; } else if ($_SESSION['language'] == "Croatian") { echo "Komentari"; } ?> </label> <textarea class="ckeditor form-control" id="editor2" name="comment" cols="10" rows="10"></textarea> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div> <span class="symbol required"></span><?php if ($_SESSION['language'] == "English") { echo "Required Fields"; } else if ($_SESSION['language'] == "Croatian") { echo "Obavezna polja"; } ?> <hr /> </div> </div> </div> <div class="row"> <div class="col-md-8"> </div> <div class="col-md-4"> <button class="btn btn-primary btn-wide pull-right" type="submit"> <?php if ($_SESSION['language'] == "English") { echo "Submit"; } else if ($_SESSION['language'] == "Croatian") { echo "Spremi"; } ?> <i class="fa fa-arrow-circle-right"></i> </button> </div> </div> </form> Javascript file is attached. This is how I initalise form validation and CKeditor. <script src="../vendor/jquery/jquery.min.js"></script> <script src="../vendor/jquery-validation/jquery.validate.min.js"></script> <script src="../vendor/ckeditor/ckeditor.js"></script> <script src="../vendor/ckeditor/adapters/jquery.js"></script> <script src="../items/js/article_validation.js"></script> <script> <script> jQuery(document).ready(function() { Main.init(); FormValidator.init(); CKEDITOR.instances."editor2".on('blur', function(){CKEDITOR.instances."editor2".updateElement();}); }); </script> Can you, please, help me? I tried everything I thought it could block it. I don't know what to do anymore.
  3. Hello all, I have a form that has a number field. It gets the max and min based on another dropdown selection. Next to the number field, I have a DIV that also changes to say what the max number is for that field. Then, I have a validator that will give an error if the person enters a number outside of that range. Min is always 1, and the max changes based not the other dropdown. It looks like this: [______] (17 seats available) If there is an error: [______] (Sorry, there are {0} seats available. Please select a number of seats between 1 and {0}) This is working great, but when someone selects a valid number, then my default text of (17 seats available) goes away. This normally wouldn't be an issue, but if they decide to change that original dropdown, the default text of available seats for that dropdown doesn't re-appear. I am wondering if I can set that default text to a "valid" response, meaning that if they select a valid number then the (17 seats available) text re-appears. Here's my js validation: jQuery.validator.setDefaults({ debug: true, success: "valid" }); $( "#registration" ).validate({ rules: { availabe_seats: { required: true, max:parseInt(available_seats) } } }); jQuery.extend(jQuery.validator.messages, { max: jQuery.validator.format(" <p style=\"color:red;display:inline\"> Sorry, there are {0} seats available. Please select a number of seats between 1 and {0}.</p>"), // display error message if there are not enough seats available. This validates number field to avoid manual entries. if using the up/down dial, it will not let the user select anything above the max anyway. }); jQuery.extend(jQuery.validator.messages, { min: jQuery.validator.format(" <p style=\"color:red;display:inline\"> Sorry, you must select at least one seat.</p>"), // display error message if there are not enough seats available. This validates number field to avoid manual entries. if using the up/down dial, it will not let the user select anything above the max anyway. }); Here's my html for where it goes: <input type="number" min="" max="" step="1" value="1" name="available_seats" id="available_seats"/> <label for="available_seats" class="error" generated="true"> (<div class="in-line"><div id="display_seats_available">0</div></div> Seats Available)<br /><br /></label> I also have additional js for the min max for the number input, and that works fine. The above js is really for the people that manually enter a number instead of using the number up/down button.
  4. I want to be able to check whether values exist in the php array without having to click the submit button to do those checks using jquery/ajax. when users enter an abbreviation in the text field want to be able to show that the brand exists (either vw or tyta) or not (as they type in the input box) and show the results in the carnamestatus div. I was following a tutorial from youtube, however it queried against a mysql database. I was wondering if this is possible using php arrays instead of mysql? I would be grateful if you could pick any faults in the code. The jquery is in the head section. the rest of the code is as follows: <?php $car = array() $car["vw"] = array( "name" => "volkswagen"); $car["tyta"] = array( "name => "toyota"); ?> the html code is as follows: <label for="carname">Car Code:</label> <input type="text" onblur="checkcar()" value="" id="carname" /> <div id="carnamestatus"></div> the checkcar() function checkcar(){ var u = _("carname").value; if(u != ""){ _("carname").innerHTML = 'checking ...'; var B = new XMLHttpRequest(); B.open("POST","check.php",true); / B.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); B.onreadystatechange = function() { if(B.readyState==4 && B.status== 200) { _("carnamestatus").innerHTML = B.responseText; } } var v = "carnamecheck="+u; B.send(v); } } </script>
  5. Hi All, I'm very new to PHP and have been reading forums for the better half of two days trying to get ot the bottom of an issue I'm having with Contact form validation. Problem: When submitting the form data, the information stored in a variable is not outputted to the webpage. What I think I'm expecting: On form submission, the HTML5 elements should be checked to see if they are empty. If they are empty, the "string" that I'm storing in the *Err variables should then be outputted on the page to advise the use that the field has not been filled in. Things I've tried: I've confirmed that Apache server is configured to allow HTML pages to be parsed as PHP and have verified that it's working by confirming that PHP scripts do run in the page, PHP includes within the HTML documents apply and that when I use <?php echo "Blah";?> on the page, it outputs correctly. When using a statement such as <?php echo $blah;?> or <?php echo "$blah";?> or <?php echo "{$blah}";?>, the content of the variable is not displayed to the user submitting the form. What am I doing wrong here? I'm trying to do this with just CSS, HTML5 and PHP - I've read about jquery and javascript but preference is to stay with the three above unless what I'm trying to do is not possible. Any pointers/assistance would be hugely appreciated - I mustn't be understanding something correctly. Cheers, A PHP Script: (P.S... I've intentionally left the mail component out until I get the form validating correctly). <?php htmlspecialchars($_SERVER["PHP_SELF"]); if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["name"])) { $nameErr = "Name is required"; echo $nameErr; } else { $name = test_input($_POST["name"]); } if (empty($_POST["email"])) { $emailErr = "Email is required"; } else { $email = test_input($_POST["email"]); } if (empty($_POST["website"])) { $website = ""; } else { $website = test_input($_POST["website"]); } if (empty($_POST["phone"])) { $website = ""; } else { $website = test_input($_POST["phone"]); } if (empty($_POST["message"])) { $comment = ""; } else { $comment = test_input($_POST["message"]); } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> Markup: <form class="form-style-9" method="post" enctype="multipart/form-data"> <ul> <li>Contact Form</li> <li> <input type="text" name="name" required class="field-style field-split align-left" placeholder="Name"><span class="error">*<?php echo $nameErr;?></span> <input type="email" name="email" required class="field-style field-split align-right" placeholder="Email"> </li> <li> <input type="tel" name="phone" required class="field-style field-split align-left" placeholder="Phone"> <input type="url" name="website" class="field-style field-split align-right" placeholder="Website"> </li> <li> <input type="text" maxlength="20" min="5" name="subject" required class="field-style field-full align-none" placeholder="Subject"> </li> <li> <textarea name="message" maxlength="200" required class="field-style" placeholder="Message"></textarea> </li> <li> <input id="submit" name="submit" type="submit" value="Send Message"> </li> </ul> </form>
  6. I am in the process of creating a script where only certains video types can be uploaded but at the moment am stuck. Here is my code - <?php $title = isset($_POST['title']) ? $_POST['title'] : null; $desc = nl2br(isset($_POST['description'])) ? $_POST['description'] : null; $name = isset($_POST['fullname']) ? $_POST['fullname'] : null; $email = isset($_POST['email']) ? $_POST['email'] : null; $country = isset($_POST['country']) ? $_POST['country'] : null; $video = isset($_FILES['video']); $videoname = isset($_FILES['video']['name']); $videotmp = isset($_FILES['video']['tmp_name']); $videosize = isset($_FILES['video']['size']); $videotype = isset($_FILES['video']['type']); $videoacceptable = array( "video/mp4", "video/ogg", "video/quicktime", ); $videopath = "/videos/"; $videofile = $videopath . $video; if(isset($_POST['submit'])) { //ERROR MESSAGES / VALIDATION if(empty($title)) { $errors[] = "A title is required"; echo "<style type=\"text/css\"> #title { background-color:#F5A9A9;border:1px solid #DF0101; } </style>"; } elseif(strlen($title) > 80) { $errors[] = "Your title can only be 80 characters long"; echo "<style type=\"text/css\"> #title { background-color:#F5A9A9;border:1px solid #DF0101; } </style>"; } if(empty($desc)) { $errors[] = "A description is required"; echo "<style type=\"text/css\"> #description { background-color:#F5A9A9;border:1px solid #DF0101; } </style>"; } if(empty($name)) { $errors[] = "Please enter your full name"; echo "<style type=\"text/css\"> #fullname { background-color:#F5A9A9;border:1px solid #DF0101; } </style>"; } elseif(strlen($name) > 32) { $errors[] = "Your name can only be 32 characters long"; echo "<style type=\"text/css\"> #fullname { background-color:#F5A9A9;border:1px solid #DF0101; } </style>"; } if(empty($email)) { $errors[] = "Please enter your email address"; echo "<style type=\"text/css\"> #email { background-color:#F5A9A9;border:1px solid #DF0101; } </style>"; } elseif(strlen($email) > 50) { $errors[] = "Your email addess can only be 50 characters long"; echo "<style type=\"text/css\"> #email { background-color:#F5A9A9;border:1px solid #DF0101; } </style>"; } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $errors[] = "Please enter a valid email address"; echo "<style type=\"text/css\"> #email { background-color:#F5A9A9;border:1px solid #DF0101; } </style>"; } if($videosize = 0) { $errors[] = "You forgot to upload a video"; } elseif($videosize >= 20000000) { $errors[] = "Your video size is too large, 20mb max"; } elseif(!in_array($videotype, $videoacceptable)) { $errors[] = "The file type is not allowed, only allowed .mp4, .ogg and .mov"; } if(count($errors) === 0) { $connect = mysqli_connect("localhost","username","password"); if(!$connect) { header("Location:"); // ADD ERROR LINK } $dbselect = mysqli_select_db("database"); if(!$dbselect) { header("Location:"); // ADD ERROR LINK } $query = mysqli_query("INSERT INTO cover_videos(title, desc, name, email, country, videotmp, videotype, videosize, videopath) VALUES('$title','$desc','$name','$email','$country','$videotmp','$videotype','$videosize','$videopath')"); move_uploaded_file($videotmp, $videofile); //SEND AN EMAIL TO THE USER $to = $email; $subject = "Thank's for your upload"; $message = ' <html> <head><title>We have received your video</title></head> <body> <h3>Good News!</h3> <p>We have recieved your video and is awaiting approval.</p> </body> </html> '; $headers = 'FROM: no-replyk' . "\r\n"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers = 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); header("Location:"); //SUCCESSFUL UPLOAD PAGE } } ?> So whats happening is when i go to upload a file, im uploading a .mov file but the error message that pops up is "The file type is not allowed, only allowed .mp4, .ogg and .mov" but the .mov mime is in the videoacceptable array so im a bit stuck at the moment, any know whats the problem?
  7. XSD <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:simpleType name="MgmtCodetyp"> <xsd:restriction base="xsd:string"> <xsd:pattern value="[A-Z][A-Z]([A-Z]|[0-9])"></xsd:pattern> </xsd:restriction> </xsd:simpleType> <xsd:element name="MgmtCode" type="MgmtCodetyp"></xsd:element> </xsd:schema> XML <MgmtCode>AGF</MgmtCode> PHP Code <?php $file = "data.xml"; function libxml_display_error($error) { $return = "\n"; switch ($error->level) { case LIBXML_ERR_ERROR: $return .= "[ERROR] "; break; case LIBXML_ERR_FATAL: $return .= "[FATAL] "; break; default: $return .= "[uNKNOWN] "; } $return .= trim($error->message); $return .= " [line: $error->line]\n"; return $return; } function libxml_display_errors() { $errors = libxml_get_errors(); foreach ($errors as $error) { if ($error -> level != LIBXML_ERR_WARNING) { print libxml_display_error($error); } } libxml_clear_errors(); } // Enable user error handling libxml_use_internal_errors(true); $xml = new DOMDocument; $xml -> load("kkk.xml"); if (!$xml -> schemaValidate("kkk.xsd")) { libxml_display_errors(); } else { print "no error\n"; } ?> OUTPUT [ERROR] Element 'MgmtCode': [facet 'pattern'] The value 'AGF' is not accepted by the pattern '[A-Z][A-Z]([A-Z]|[0-9])'. [line: 1] [ERROR] Element 'MgmtCode': 'AGF' is not a valid value of the atomic type 'MgmtCodetyp'. [line: 1] ANALYSIS The XML is a perfectly valid xml. I don't understand why it failed the XSD.
  8. Hi all, I am trying to validate my contact page for phone # and country. I am not able to show warnings for country and phone#. Not sure what needs to be done. Please help. The code is as below <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Contact Us</title> <style> .error {color: #FF0000;} </style> </head> <body> <?php // define variables and set to empty values $nameErr = $emailErr = $genderErr = $websiteErr = $countryErr = $phonenoErr = ""; $name = $email = $gender = $comment = $website = $country = $phoneno = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["name"])) { $nameErr = "Name is required"; } else { $name = test_input($_POST["name"]); // check if name only contains letters and whitespace if (!preg_match("/^[a-zA-Z ]*$/",$name)) { $nameErr = "Only letters and white space allowed"; } } if (empty($_POST["email"])) { $emailErr = "Email is required"; } else { $email = test_input($_POST["email"]); // check if e-mail address syntax is valid if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email)) { $emailErr = "Invalid email format"; } } if (empty($_POST["website"])) { $website = ""; } else { $website = test_input($_POST["website"]); // check if URL address syntax is valid (this regular expression also allows dashes in the URL) if (!preg_match("/\b(??:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$website)) { $websiteErr = "Invalid URL"; } } if (empty($_POST["comment"])) { $comment = ""; } else { $comment = test_input($_POST["comment"]); } if (empty($_POST["gender"])) { $genderErr = "Gender is required"; } else { $gender = test_input($_POST["gender"]); } { if (empty($_POST["country"])) { $nameErr = "Please select your country"; } else { $name = test_input($_POST["country"]); }} } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> <h2>Contact Us</h2> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> Name: <input type="text" name="name"> <span class="error">* <?php echo $nameErr;?></span> <br><br> E-mail: <input type="text" name="email"> <span class="error">* <?php echo $emailErr;?></span> <br><br> <!--Website: <input type="text" name="website">--> <span class="error"><?php echo $websiteErr;?></span> <br><br> Gender: <input type="radio" name="gender" value="female">Female <input type="radio" name="gender" value="male">Male <span class="error">* <?php echo $genderErr;?></span> <br><br> <label for="country">Country:</label> <select name="country"> <option value='Choose your country' selected='selected'></option> <option value="AF">Afghanistan</option> <option value="AX">Ã…Land Islands</option> <option value="AL">Albania</option> <option value="DZ">Algeria</option> <option value="AS">American Samoa</option> <option value="AD">Andorra</option> <option value="AO">Angola</option> <option value="AI">Anguilla</option> <option value="AQ">Antarctica</option> <option value="AG">Antigua And Barbuda</option> <option value="AR">Argentina</option> <option value="AM">Armenia</option> <option value="AW">Aruba</option> <option value="AU">Australia</option> <option value="AT">Austria</option> <option value="AZ">Azerbaijan</option> <option value="BS">Bahamas</option> <option value="BH">Bahrain</option> <option value="BD">Bangladesh</option> <option value="BB">Barbados</option> <option value="BY">Belarus</option> <option value="BE">Belgium</option> <option value="BZ">Belize</option> <option value="BJ">Benin</option> <option value="BM">Bermuda</option> <option value="BT">Bhutan</option> <option value="BO">Bolivia</option> <option value="BA">Bosnia And Herzegovina</option> <option value="BW">Botswana</option> <option value="BV">Bouvet Island</option> <option value="BR">Brazil</option> <option value="IO">British Indian Ocean Territory</option> <option value="BN">Brunei Darussalam</option> <option value="BG">Bulgaria</option> <option value="BF">Burkina Faso</option> <option value="BI">Burundi</option> <option value="KH">Cambodia</option> <option value="CM">Cameroon</option> <option value="CA">Canada</option> <option value="CV">Cape Verde</option> <option value="KY">Cayman Islands</option> <option value="CF">Central African Republic</option> <option value="TD">Chad</option> <option value="CL">Chile</option> <option value="CN">China</option> <option value="CX">Christmas Island</option> <option value="CC">Cocos (Keeling) Islands</option> <option value="CO">Colombia</option> <option value="KM">Comoros</option> <option value="CG">Congo</option> <option value="CD">Congo, The Democratic Republic Of The</option> <option value="CK">Cook Islands</option> <option value="CR">Costa Rica</option> <option value="CI">Cote D'Ivoire</option> <option value="HR">Croatia</option> <option value="CU">Cuba</option> <option value="CY">Cyprus</option> <option value="CZ">Czech Republic</option> <option value="DK">Denmark</option> <option value="DJ">Djibouti</option> <option value="DM">Dominica</option> <option value="DO">Dominican Republic</option> <option value="EC">Ecuador</option> <option value="EG">Egypt</option> <option value="SV">El Salvador</option> <option value="GQ">Equatorial Guinea</option> <option value="ER">Eritrea</option> <option value="EE">Estonia</option> <option value="ET">Ethiopia</option> <option value="FK">Falkland Islands (Malvinas)</option> <option value="FO">Faroe Islands</option> <option value="FJ">Fiji</option> <option value="FI">Finland</option> <option value="FR">France</option> <option value="GF">French Guiana</option> <option value="PF">French Polynesia</option> <option value="TF">French Southern Territories</option> <option value="GA">Gabon</option> <option value="GM">Gambia</option> <option value="GE">Georgia</option> <option value="DE">Germany</option> <option value="GH">Ghana</option> <option value="GI">Gibraltar</option> <option value="GR">Greece</option> <option value="GL">Greenland</option> <option value="GD">Grenada</option> <option value="GP">Guadeloupe</option> <option value="GU">Guam</option> <option value="GT">Guatemala</option> <option value="Gg">Guernsey</option> <option value="GN">Guinea</option> <option value="GW">Guinea-Bissau</option> <option value="GY">Guyana</option> <option value="HT">Haiti</option> <option value="HM">Heard Island And Mcdonald Islands</option> <option value="VA">Holy See (Vatican City State)</option> <option value="HN">Honduras</option> <option value="HK">Hong Kong</option> <option value="HU">Hungary</option> <option value="IS">Iceland</option> <option value="IN">India</option> <option value="ID">Indonesia</option> <option value="IR">Iran, Islamic Republic Of</option> <option value="IQ">Iraq</option> <option value="IE">Ireland</option> <option value="IM">Isle Of Man</option> <option value="IL">Israel</option> <option value="IT">Italy</option> <option value="JM">Jamaica</option> <option value="JP">Japan</option> <option value="JE">Jersey</option> <option value="JO">Jordan</option> <option value="KZ">Kazakhstan</option> <option value="KE">Kenya</option> <option value="KI">Kiribati</option> <option value="KP">Korea, Democratic People'S Republic Of</option> <option value="KR">Korea, Republic Of</option> <option value="KW">Kuwait</option> <option value="KG">Kyrgyzstan</option> <option value="LA">Lao People'S Democratic Republic</option> <option value="LV">Latvia</option> <option value="LB">Lebanon</option> <option value="LS">Lesotho</option> <option value="LR">Liberia</option> <option value="LY">Libyan Arab Jamahiriya</option> <option value="LI">Liechtenstein</option> <option value="LT">Lithuania</option> <option value="LU">Luxembourg</option> <option value="MO">Macao</option> <option value="MK">Macedonia, The Former Yugoslav Republic Of</option> <option value="MG">Madagascar</option> <option value="MW">Malawi</option> <option value="MY">Malaysia</option> <option value="MV">Maldives</option> <option value="ML">Mali</option> <option value="MT">Malta</option> <option value="MH">Marshall Islands</option> <option value="MQ">Martinique</option> <option value="MR">Mauritania</option> <option value="MU">Mauritius</option> <option value="YT">Mayotte</option> <option value="MX">Mexico</option> <option value="FM">Micronesia, Federated States Of</option> <option value="MD">Moldova, Republic Of</option> <option value="MC">Monaco</option> <option value="MN">Mongolia</option> <option value="MS">Montserrat</option> <option value="MA">Morocco</option> <option value="MZ">Mozambique</option> <option value="MM">Myanmar</option> <option value="NA">Namibia</option> <option value="NR">Nauru</option> <option value="NP">Nepal</option> <option value="NL">Netherlands</option> <option value="AN">Netherlands Antilles</option> <option value="NC">New Caledonia</option> <option value="NZ">New Zealand</option> <option value="NI">Nicaragua</option> <option value="NE">Niger</option> <option value="NG">Nigeria</option> <option value="NU">Niue</option> <option value="NF">Norfolk Island</option> <option value="MP">Northern Mariana Islands</option> <option value="NO">Norway</option> <option value="OM">Oman</option> <option value="PK">Pakistan</option> <option value="PW">Palau</option> <option value="PS">Palestinian Territory, Occupied</option> <option value="PA">Panama</option> <option value="PG">Papua New Guinea</option> <option value="PY">Paraguay</option> <option value="PE">Peru</option> <option value="PH">Philippines</option> <option value="PN">Pitcairn</option> <option value="PL">Poland</option> <option value="PT">Portugal</option> <option value="PR">Puerto Rico</option> <option value="QA">Qatar</option> <option value="RE">Reunion</option> <option value="RO">Romania</option> <option value="RU">Russian Federation</option> <option value="RW">Rwanda</option> <option value="SH">Saint Helena</option> <option value="KN">Saint Kitts And Nevis</option> <option value="LC">Saint Lucia</option> <option value="PM">Saint Pierre And Miquelon</option> <option value="VC">Saint Vincent And The Grenadines</option> <option value="WS">Samoa</option> <option value="SM">San Marino</option> <option value="ST">Sao Tome And Principe</option> <option value="SA">Saudi Arabia</option> <option value="SN">Senegal</option> <option value="CS">Serbia And Montenegro</option> <option value="SC">Seychelles</option> <option value="SL">Sierra Leone</option> <option value="SG">Singapore</option> <option value="SK">Slovakia</option> <option value="SI">Slovenia</option> <option value="SB">Solomon Islands</option> <option value="SO">Somalia</option> <option value="ZA">South Africa</option> <option value="GS">South Georgia And The South Sandwich Islands</option> <option value="ES">Spain</option> <option value="LK">Sri Lanka</option> <option value="SD">Sudan</option> <option value="SR">Suriname</option> <option value="SJ">Svalbard And Jan Mayen</option> <option value="SZ">Swaziland</option> <option value="SE">Sweden</option> <option value="CH">Switzerland</option> <option value="SY">Syrian Arab Republic</option> <option value="TW">Taiwan, Province Of China</option> <option value="TJ">Tajikistan</option> <option value="TZ">Tanzania, United Republic Of</option> <option value="TH">Thailand</option> <option value="TL">Timor-Leste</option> <option value="TG">Togo</option> <option value="TK">Tokelau</option> <option value="TO">Tonga</option> <option value="TT">Trinidad And Tobago</option> <option value="TN">Tunisia</option> <option value="TR">Turkey</option> <option value="TM">Turkmenistan</option> <option value="TC">Turks And Caicos Islands</option> <option value="TV">Tuvalu</option> <option value="UG">Uganda</option> <option value="UA">Ukraine</option> <option value="AE">United Arab Emirates</option> <option value="GB">United Kingdom</option> <option value="US">United States</option> <option value="UM">United States Minor Outlying Islands</option> <option value="UY">Uruguay</option> <option value="UZ">Uzbekistan</option> <option value="VU">Vanuatu</option> <option value="VE">Venezuela</option> <option value="VN">Viet Nam</option> <option value="VG">Virgin Islands, British</option> <option value="VI">Virgin Islands, U.S.</option> <option value="WF">Wallis And Futuna</option> <option value="EH">Western Sahara</option> <option value="YE">Yemen</option> <option value="ZM">Zambia</option> <option value="ZW">Zimbabwe</option> </select> <span class="error"><?php echo $countryErr; ?></span> <br><br> <label for="phone">Phone Number (With Country Code):</label> <input id="phone" name="phone" class="text" /> <span class="error"><?php echo $phonenoErr;?></span> <br><br> Comment: <textarea name="comment" rows="5" cols="40"></textarea> <br><br> <input type="submit" name="submit" value="Submit"> </form>
  9. Good evening, I am working on a birthday validation using Jquery datepicker. I am trying to make the birthday section validate whether the birthday input is in a date format and I want to prevent users under 18 from join. Thank you accountsettings.php <input type="text" name="Birthday" id="Birthday" maxlength="50" value=" <?php if($form->value("Birthday") == ""){ echo $session->userinfo['Birthday']; }else{ echo $form->value("Birthday"); } ?>"> process.php function register( $subuser, $subconfirmuser, $subpass, $subconfirmpass, $subemail, $subconfirmemail, $subFirstname, $subLastname, $subGender, $subBirthday, $subRegion, $subCountry, $subCity_State, $subQuestion, $subAnswer, $subConfirmAnswer){ global $database, $form, $mailer; //The database, form and mailer object /* Birthday error checking */ $field = "Birthday"; //Use field name for Birthday if(!$subBirthday || strlen($subBirthday = trim($subBirthday)) == 0){ $form->setError($field, "* Birthday not entered"); } else{ /* I've attempted different formulas but it did not work here */ $date = date('yyyy-mm-dd'); if( $subBirthday > $date){ $form->setError($field, "* You are too young!"); } }
  10. Hello everyone! I'm new to PHP (and to this forum, too). My final goal is to make a script that recognises which websites have an Extended Validation certificate type and which ones do not. Except I don't know how to do it. For starters, I should download the X.509 certificate and analyse it (I use both the OpenSSL and cURL PHP extensions), but how? DAYS of googling have brought me absolutely nothing. Any tips are appreciated. I can provide more detail if need be. I'd provide source code if I had any but I really don't know where to start... Thanks!
  11. I am writing a script that will parse my PHP classes and check for things like coupling, visualize my objects and connections, dependencies, check for convention usage, etc. So, I have a simple file upload. I'm never saving the files, just get contents and dump the file and work with the string version. I'm writing it for me, but I figure I might want to open it for others to use in the future, so I may as well write it that way to begin with -- so I need to validate user input. Problem is, the user input is supposed to be valid PHP code. I'm thinking that, as long as I'm careful, I shouldn't be executing any code contained in strings, but I'm no security expert and I want a warm fuzzy that my thought on this is correct. What kinds of things do I need to look out for? Is it possible to inject when working with strings? My initial thought is to regex the entire file and replace key portions with known replacements. So ( and ) would become !* and !^ or $ would become @~ (combinations that -- I think -- don't make sense to php?) But that may be completely unnecessary processing time if I'm not in any danger, here. Thanks ahead of time for any help. PS - as a side question -- what's the best way to verify a file is a php file? I know of getimagesize for images, but should I just check for <? to verify it's php? That seems like it would be too easy to fool -- then again, it might not matter much. -Adam
  12. HI, I am a beginner at programing and I have to do this project where it is asking me to validate any ISBN 13 number. I know how to set up the input page, but I am having or you could say no Idea how to validate a number if user inputs data in the input page. I have some could below that I think it should be included, but if someone has better way to do it then I would be appreciate it. here is the input page code: <form method="POST" action="Process_isbn13.php"> <p>Enter the ISBN 13: <input type="text" name="isbn13"/></p> <input type="submit" name="Submit" value="Submit" /> </form> I have this so far for my processing page to validate the ISBN 13 number! <?php function isValidISBN13($isbn) { $sum = 0; for ($i = 0; $i < 13; $i++) { if ($isbn[$i] === 'X') { $value = 13; } else { $value = $isbn[$i]; } $sum += ($i + 1) * $value; } } ?> I know there should be more like if it is empty it should say it's empty do it again and if it is not validate then it would say that. The most important thing I need is the code so if i enter a validate ISBN 13 number it would say it's validate! Someone please help me with the code needed to check if ISBN 13 number is validate.
  13. This is the project I need to finish. I am fairly new to php and this project has got me confused. Any help would be greatly appreciated The project ask for to validate ISBN 10 Number. There would be 10 digits with 1-9 being Numbers, but Number 10 is an x. This is What I have so far: This is the input page or html page: <form method="POST" action="Process10ISBN.php"> <p>Enter ISBN 10: <input type="text" name="isbn10" /></p> <input type="submit" name="Submit" value="Submit" /> </form> This is what I have so far for the Procssing page to validate ISBN 10: <?php if (empty($_POST['isbn10'])) echo "<p>Please Fill in the input fields. Please use the back button to re-enter the data!</p>\n"; else { $ISBN10 = addslashes($_POST['isbn10']); echo "<p>Thank you for your input!</p>\n"; } //this are the code that should go in the project $chk_sum_num=10; for($i=0;$i<=9;$i++ { $chk_sum+=$ISBN_Arr[$i] * $chk_sum_num; print"$ISBN_Arr[$i] | $chk_sum_num<br/>"; $chk_sum_num--; }//end for loop //this goes at top, then the loop goes inside it If $ISBNARR[9]!=is numeric{{!= 'X'!!='x' print"Not ISBN 10 Number<br/>"; Else If $ISBNARR[9]=='x' or "X" $ISBNARR[9] = 10 ?><!--End PHP Script--> // I don't know how to set up the processing page. All I know is that this code has to be included in the processing page: I know my processing code is set up wrong. I couldn't figure out how I would put the codes in and what else I needed to add! //this are the code that should go in the project $chk_sum_num=10; for($i=0;$i<=9;$i++ { $chk_sum+=$ISBN_Arr[$i] * $chk_sum_num; print"$ISBN_Arr[$i] | $chk_sum_num<br/>"; $chk_sum_num--; }//end for loop //this goes at top, then the loop goes inside it If $ISBNARR[9]!=is numeric{{!= 'X'!!='x' print"Not ISBN 10 Number<br/>"; Else If $ISBNARR[9]=='x' or "X" $ISBNARR[9] = 10 ?><!--End PHP Script--> Can Someone show me how I am suppose to do the processing page for my ISBN 10 validation! Thank You!
  14. Hello everyone, I'm been racking my brain for far too long, and I need help. I'm just not as advanced in PHP yet to get this. Here is what I am trying to do: - A user submits a simple form from form.php - Form data is sent to validateform.php - Form data is validated - If there's an error: display the error to the user back on form.php, otherwise: - Include a few more bits of information (I'm not supposed to keep them as hidden fields on the form page) - Send it all to a process.do script on some other server It should be easy enough, but I can't wrap my head around it all yet. Here is roughly what I got, cleaned up and trimmed down to exclude all of the messy incorrect code I've been messing around with. // Code for form.php // <form action="validateform.php" method="post"> <input type="text" name="field1" placeholder="Field1 Data"> <input type="text" name="field2" placeholder="Field2 Data"> <input type="text" name="field3" placeholder="Field3 Data"> <input type="text" name="field4" placeholder="Field4 Data"> <input type="submit" value="Submit Form"> </form> // Code for validateform.php // $field1 = $_POST['field1']; $field2 = $_POST['field2']; $field3 = $_POST['field3']; $field4 = $_POST['field4']; // if/else validation script code goes here // // Somehow add in the following data // // It was orignaly in the form.php page as hidden text fields, but I've been told I'm not supposed to do that for secureity reasons) name="hiddendata1" value="Data" name="hiddendata2" value="Data" name="hiddendata2" value="Data" // Code that sends all the data to process.do // If you guys could give me any help on this I would really appreciate it. Thank you.
  15. I am trying to implement a validation process within the php wrapper for the new form. The automatically gets submitted and completely ignores the validation process. Is there any reason why? <?php //Initialize the $query_string variable for later use $query_string = ""; //If there are POST variables if ($_POST) { //Initialize the $kv array for later use $kv = array(); //For each POST variable as $name_of_input_field => $value_of_input_field foreach ($_POST as $key => $value) { //Set array element for each POST variable (ie. first_name=Arsham) $kv[] = stripslashes($key)."=".stripslashes($value); } //Create a query string with join function separted by & $query_string = join("&", $kv); } //Check to see if cURL is installed ... if (!function_exists('curl_init')){ die('Sorry cURL is not installed!'); } //The original form action URL from Step 2 $url = 'https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8'; //Open cURL connection $ch = curl_init(); if(isset($_POST['submit'])){ if($_POST['first_name'] == ""){ $error="Please enter a topic<br>"; } if($_POST['last_name'] == ""){ $error="Please enter a topic<br>"; } if($_POST['phone'] == ""){ $error="Please enter a topic<br>"; } if($_POST['email'] == ""){ $error="Please enter a topic<br>"; } if($_POST['company'] == ""){ $error="Please enter a topic<br>"; } if(isset($error)){ echo $error; }else{ // Both fields have content in } } //Set the url, number of POST vars, POST data curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, count($kv)); curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string); //Set some settings that make it all work curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, FALSE); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); //Execute SalesForce web to lead PHP cURL $result = curl_exec($ch); //close cURL connection curl_close($ch); ?>
  16. Hi all, I am trying to validate a form, but run into some troubles... Full Name This works up until a space is present then fails, any suggestions? // # Fullname if (isset($_POST["Fullname"])){ $fnop = $_POST["Fullname"]; if (ctype_alpha($fnop)) { echo "</BR>PASSED! : FULLNAME : $fnop"; } else { echo "</BR>FAILED! : FULLNAME : $fnop"; } }; Test case: INPUT: 123456789 | OUTPUT: FAILED; INPUT: ABCD1234 | OUTPUT: FAILED; INPUT: AbCdEfGh | OUTPUT: PASSED; INPUT: AbC<Space>DeF | OUTPUT: FAILED; Phone number This works up until a 0 is in the number and then fails, any suggestions? // # Contact Num if (isset($_POST["Phone"])){ $phoneop = $_POST["Phone"]; if (filter_var($phoneop, FILTER_VALIDATE_INT)) { echo "</BR>PASSED! : PHONE : $phoneop"; } else { echo "</BR>FAILED! : PHONE : $phoneop"; } }; Test case: INPUT: 123456789 | OUTPUT: PASSED; INPUT: ABCD1234 | OUTPUT: FAILED; INPUT: AbCdEfGh | OUTPUT: FAILED; INPUT: 0432666777 | OUTPUT: FAILED; Kind regards and advance thanks.
  17. I'm wondering the best way to handle validation messages for blind people, or sight-impaired. In my application, the situation on a save with errors is: User clicks save AJAX call goes to save the record; wait bar appears on the page's status bar Error is returned. The wait bar changes to show "Error on save" Below the status bar, each field name is listed with the appropriate error message. ("Name - Cannot be blank" or whatever) Within the fields themselves, the same message is shown again. (Next to the "Name" label on the page, "cannot be blank" would show up.) This functionality is great for sighted people. But for non-sighted, I'm not sure exactly how to handle it. Should an error become "selected" or something? I mean, it's just a div. I don't really have the answer. I posted this in general HTML but it could frankly be AJAX or JS or something. I think HTML is probably the most correct.
  18. I need to check if the input is a valid email or not if the email is not valid then it would ask again for the mail address without refreshing the whole page. </script> <?php error_reporting(E_ALL); if($_POST['submit']=="India") { if(isset($_POST['EMAIL'])) { //only do file operations when appropriate $a = $_POST['EMAIL']; $myFile = "email_users.txt"; $d=date("d-m-y"); $r="\n"; $s=$_POST['submit']; $fh = fopen($myFile, 'a+') or die("can't open file"); fwrite($fh, $a.','.$d.','.$s.','.$r); fclose($fh); } } if($_POST['sub']=="Overseas") { if(isset($_POST['EMAIL'])) { //only do file operations when appropriate $b = $_POST['EMAIL']; $my = "email_users.txt"; $e=date("d-m-y"); $t="\n"; $u=$_POST['sub']; $f = fopen($my, 'a+') or die("can't open file"); fwrite($f, $b.','.$e.','.$u.','.$t); fclose($f); } } //header("location:http://www.xyz.com"); ?> Please help me urgently Thanks in advance
  19. I have in promotie.php the next form: <form accept-charset="UTF-8" action="redirect.php"> <input name="code" type="text" id="code" maxlength="15" /> <input type="submit" value="Submit"/> </form> In redirect.php I have this code: <?php header('Location: download.php?code='.$_POST['code']); ?>What I want to do is the next thing: I will create a file code.txt, where I write on each line my promotional codes. Now how can I redirect to promotieerror.php or show a error if the code that was writed by the user doesn't exist in code.txt ? P.S.: I don't want to use MySQL/Databases. Thanks in advance for help.
  20. <!DOCTYPE HTML> <html> <head> <style> .error {color: #FF0000;} </style> </head> <body> <?php $con = mysqli_connect("localhost","root","","nib"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // define variables and set to empty values $companynameErr = $firstnameErr = $genderErr = $address1Err = $address2Err = $areaErr = $cityErr = ""; $companyname = $firstname = $gender = $comment = $address1 = $address2 = $area = $city = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["companyname"])) {$companynameErr = "companyname is required";} else {$companyname = test_input($_POST["companyname"]);} if (empty($_POST["firstname"])) {$firstnameErr = "firstname is required";} else {$firstname = test_input($_POST["firstname"]);} if (empty($_POST["address1"])) {$address1 = "";} else {$address1 = test_input($_POST["address1"]);} if (empty($_POST["address2"])) {$address2 = "";} else {$address2 = test_input($_POST["address2"]);} if (empty($_POST["area"])) {$area = "";} else {$area = test_input($_POST["area"]);} if (empty($_POST["city"])) {$city = "";} else {$city = test_input($_POST["city"]);} } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> <h2>PHP Form Validation</h2> <p><span class="error">* required field.</span></p> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <table border = "0"> <tr> <td>company name:</td><td> <input type="text" name="companyname"></td> <td><span class="error">* <?php echo $companynameErr;?></span></td> <tr> <tr> <td>First Name:</td><td> <input type="text" name="firstname"></td> <td><span class="error">* <?php echo $firstnameErr;?></span></td> </tr> <tr> <td>address1:</td><td> <input type="text" name="address1"></td> <td><span class="error">*<?php echo $address1Err;?></span></td> </tr> <tr> <td>address2:</td><td><input type="text" name="address2"></td> <td><span class="error">* <?php echo $address2Err;?></span></td> </tr> <tr> <td>area:</td> <td><input type="text" name="area"></td> <td><span class="error">* <?php echo $areaErr;?></span></td> </tr> <tr> <td>city:</td> <td><input type="text" name="city"></td> <td><span class="error">* <?php echo $cityErr;?></span></td> </tr> <tr> <td><input type="submit" name="submit" value="Submit"></td> </tr> <?$sql="INSERT INTO tbl_club_contacts (CompanyName, FirstName, Address1, Address2, Area, City) VALUES ('$_POST[companyname]','$_POST[firstname]','$_POST[address1]','$_POST[address2]','$_POST[area]','$_POST[city]')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } mysqli_close($con); ?> </form> </body> </html> right ive been doing this for a while now and i really wana get this out the way what i wana do is check fields if they are empty if they are empty a message will appear saying that all fields need to be filled and if all are filled it will send the data filled in to a database please help im getting bored of this now.
  21. hi i want to put a validation in my code so it will check all fields if they have been used ive got the code pretty much sorted but they i think they is one problem with it on line 30 <!DOCTYPE HTML> <html> <head> <style> .error {color: #FF0000;} </style> </head> <body> <? $con = mysqli_connect("","","",""); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } mysqli_query($con,"INSERT INTO tbl_club_contacts (CompanyName, FirstName, Address1, Address2, Area, City); VALUES ('nelsons', 'luke', '', 'IT', '5 HIGHFIELD ROAD', 'LITTLEOVER', 'DERBY')"); mysqli_close($con); // define variables and set to empty values $companynameErr = $FirstNameErr = $Address1Err = $Address2Err = $AreaErr = $CityErr = ""; $companyname = $FirstName = $Address1 = $Address2 = $Area = $City = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") $allValid = true; if(validation fails); { $allValid = false; } if($allValid) { // connect to db, create query, execute query } As for checking the values you could if($_POST['companyname']==null || $_POST['companyname']=="") { $allValid = false; } ?> <form action="insertaddleads.php" method="post"> <p><span class="error">* required field.</span></p> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> CompanyName: <input type="text" name="companyname"> <span class="error">* <?php echo $CompanyNameErr;?></span> <br><br> FirstName: <input type="text" name="firstname"> <span class="error">* <?php echo $FirstNameErr;?></span> <br><br> Address 1: <input type="text" name="address1"> <span class="error">* <?php echo $Address1Err;?></span> <br><br> Address 2: <input type="text" name="address2"> <span class="error">* <?php echo $Address2Err;?></span> <br><br> Area: <input type="text" name="area"> <span class="error">* <?php echo $AreaErr;?></span> <br><br> City: <input type="text" name="city"> <span class="error">* <?php echo $CityErr;?></span> <br><br> <input type="submit" name="submit" value="Submit"> </form> <? echo $CompanyName; echo "<br>"; echo $FirstName; echo "<br>"; echo $Address1; echo "<br>"; echo $Address2; echo "<br>"; echo $Area; echo "<br>"; echo $City; echo "<br>"; ?> <?php foreach($_POST as $fieldName=>$fieldValue) { if($fieldValue == '') { print "<div>$fieldName is blank</div>"; } } ?> </body> </html> heres the insert just incase <?php $con=mysqli_connect("","","",""); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql="INSERT INTO tbl_club_contacts (CompanyName, FirstName, Address1, Address2, Area, City) VALUES ('$_POST[companyname]','$_POST[firstname]','$_POST[address1]','$_POST[address2]','$_POST[area]','$_POST[city]')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } echo "record added"; mysqli_close($con); ?> <html> <body> <form action="addleads2.php" method="post"> <input type="submit", value = "go back"> </form> </body> </html>
  22. hi i really need your help what im trying to do is check if form fields are empty and then if so stop users from going any further i got the jist sorted e.g. send data to a database and this is the main code <?php $con=mysqli_connect("","","",""); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql="INSERT INTO tbl_club_contacts (CompanyName) VALUES ('$_POST[CompanyName]')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } echo "record added"; mysqli_close($con); ?> <html> <body> <form action="copyofaddleads2.php" method="post"> <input type="submit", value = "go back"> </form> </body> </html> heres the insert document <?php $con=mysqli_connect("","","",""); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql="INSERT INTO tbl_club_contacts (CompanyName, FirstName, Address1, Address2, Area, City) VALUES ('$_POST[companyname]','$_POST[firstname]','$_POST[address1]','$_POST[address2]','$_POST[area]','$_POST[city]')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } echo "record added"; mysqli_close($con); ?> <html> <body> <form action="addleads2.php" method="post"> <input type="submit", value = "go back"> </form> </body> </html>
  23. Hello, I am looking for someone that can redesign my old form and make some validation changes... Things I need the form to do: Confirm leaving the page, if it is done other than by submitting the form There is a place for three different phone numbers, home, work, and mobile, I only need to ensure that at least one of those is filled out, more can be, but one is required Proper character input type validation, phone numbers, zip code, email address Required fields, some of which are of the HTML "select" type of input Format masking, e.g. phone numbers Needs to be multi-browser compatible, Firefox, Chrome, IE, Safari The form needs to be smooth and curvy, very jQuery / AJAX Convert the MySQL to MySQLi The form should have it's own css, so that it can stand alone on it's own, but not conflict with other css either, e.g. start all of it's css with something like "form_" or something Improve upon the PHP as you see fit If you can make or add a better way to put in a date of birth, other than 3 drop-down boxes, then that would be good as well In the form there is also a question of whether or not an address is the same as another address, if so, it copies the address info, if not, it shows a new div, for a new address, the form will still need that functionality as well P.S. The form is called via an SSL secure page Please contact me with your quotes and any forms that you would like to show off, at motorsportfun2013 [@] gmail dot com Since I apparently can't attach the page, I'll post the code of what I'm currently using... <? require 'includes/auth.php'; $AgentID = $_SESSION['AgentID']; $AgentName = $_SESSION['AgentName']; if (isset($_GET['orderticketid'])) { $orderticketid = clean($_GET['orderticketid']); $result = mysql_query(" SELECT OrderTickets.*, Agencies.AgencyName, InsuranceCarriers.InsuranceCarrier FROM OrderTickets LEFT JOIN Agencies ON OrderTickets.AgencyID = Agencies.AgencyID LEFT JOIN InsuranceCarriers ON OrderTickets.InsuranceCarrierID = InsuranceCarriers.InsuranceCarrierID WHERE OrderTickets.OrderTicketID = '$orderticketid' AND OrderTickets.AgentID = '$AgentID' "); while ($OrderTicketRow = mysql_fetch_assoc($result)) { $InsuranceCarrierID = $OrderTicketRow['InsuranceCarrierID']; $InsuranceCarrierPolicyNumber = $OrderTicketRow['InsuranceCarrierPolicyNumber']; $OrderTicketFirstName = $OrderTicketRow['OrderTicketFirstName']; $OrderTicketMiddleName = $OrderTicketRow['OrderTicketMiddleName']; $OrderTicketLastName = $OrderTicketRow['OrderTicketLastName']; $OrderTicketAddress = $OrderTicketRow['OrderTicketAddress']; $OrderTicketCity = $OrderTicketRow['OrderTicketCity']; $OrderTicketState = $OrderTicketRow['OrderTicketState']; $OrderTicketZipCode = $OrderTicketRow['OrderTicketZipCode']; $OrderTicketExamLocation = $OrderTicketRow['OrderTicketExamLocation']; $OrderTicketExamLocationAddress = $OrderTicketRow['OrderTicketExamLocationAddress']; $OrderTicketExamLocationCity = $OrderTicketRow['OrderTicketExamLocationCity']; $OrderTicketExamLocationState = $OrderTicketRow['OrderTicketExamLocationState']; $OrderTicketExamLocationZipCode = $OrderTicketRow['OrderTicketExamLocationZipCode']; $OrderTicketHomePhone = $OrderTicketRow['OrderTicketHomePhone']; $OrderTicketWorkPhone = $OrderTicketRow['OrderTicketWorkPhone']; $OrderTicketMobilePhone = $OrderTicketRow['OrderTicketMobilePhone']; $OrderTicketEmailAddress = $OrderTicketRow['OrderTicketEmailAddress']; $OrderTicketDOBMonth = date('m', strtotime($OrderTicketRow['OrderTicketDOB'])); $OrderTicketDOBDay = date('d', strtotime($OrderTicketRow['OrderTicketDOB'])); $OrderTicketDOBYear = date('Y', strtotime($OrderTicketRow['OrderTicketDOB'])); $OrderTicketGender = $OrderTicketRow['OrderTicketGender']; $OrderTicketSmoker = $OrderTicketRow['OrderTicketSmoker']; $OrderTicketPolicyType = $OrderTicketRow['OrderTicketPolicyType']; $OrderTicketPolicyAmount = $OrderTicketRow['OrderTicketPolicyAmount']; $OrderTicketSpecialInstructions = $OrderTicketRow['OrderTicketSpecialInstructions']; } } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link href="StyleSheet.css" rel="stylesheet" type="text/css" /> <link rel="shortcut icon" href="images/favicon.ico" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script> <script type="text/javascript" src="includes/JavaScriptValidationFunctions.js"></script> <script type="text/javascript" src="includes/Modernizr-2.5.3.forms.js"></script> <script type="text/javascript" data-webforms2-support="validation" src="includes/html5Forms.js"></script> <script src="includes/jquery.maskedinput-1.3.min.js" type="text/javascript"></script> <script type="text/javascript"> jQuery(document).ready(function() { jQuery("#OrderTicketHomePhone").mask("(999) 999-9999"); jQuery("#OrderTicketWorkPhone").mask("(999) 999-9999"); jQuery("#OrderTicketMobilePhone").mask("(999) 999-9999"); }); </script> <script type="text/javascript"> window.onbeforeunload = function() { return 'You have unsaved changes!'; } </script> <script type="text/javascript"> function ShowHide(){ if (document.getElementById("OrderTicketExamLocation").value == '') { $('.show_hide').hide(); } if (document.getElementById("OrderTicketExamLocation").value != 'Home') { $('.show_hide').show(); } else if (document.getElementById("OrderTicketExamLocation").value == 'Home') { $('.show_hide').hide(); } } </script> <title>Submit Order Ticket</title> </head> <body> <div id="LogoHeader"> <img src="images/logo.png" /> </div> <div id="Menu"> <? include 'includes/menu.php'; ?> </div> <div class="jQueryErrors"> </div> <div id="OrderForm"> <br /> <form id="submitorderform" action="submitorderticket-action.php" method="post" onsubmit="return validateOrderSubmissionForm();"> <input id="submitneworderticket" name="submitneworderticket" value="submitneworderticket" type="hidden" /> <fieldset> <div class="FormRow"> <div class="FormLabel"> <label for="InsuranceCarrierID">* Insurance Carrier:</label> </div> <div class="FormInput"> <? $CarriersResult = mysql_query("SELECT InsuranceCarriersAgents.InsuranceCarrierID, InsuranceCarriers.InsuranceCarrier FROM InsuranceCarriersAgents LEFT JOIN InsuranceCarriers ON InsuranceCarriersAgents.InsuranceCarrierID = InsuranceCarriers.InsuranceCarrierID WHERE InsuranceCarriersAgents.AgentID = '$AgentID'") or die(mysql_error()); $rowCounter = mysql_num_rows($CarriersResult); if ($rowCounter == 0) { echo '<span style="background-color: #C0C0C0; color: red; padding: 2px;">You Are Not Associated With Any Insurance Carriers, Click On <a href="carrier-agent-correlations.php">Insurance Carriers</a> To Add It/Them.<span>'; } if ($rowCounter > 1) { echo '<select id="InsuranceCarrierID" name="InsuranceCarrierID">'; echo '<option value=""> ... </option>'; } while ($temprow = mysql_fetch_assoc($CarriersResult)) { if ($rowCounter == 1) { echo '<input type="hidden" id="InsuranceCarrierID" name="InsuranceCarrierID" value="'.$temprow['InsuranceCarrierID'].'" />'; echo '<input style="color: #515151;" type="text" id="InsuranceCarrier" name="InsuranceCarrier" value="'.$temprow['InsuranceCarrier'].'" size="50" READONLY />'; } if ($rowCounter > 1) { echo '<option value="'.$temprow['InsuranceCarrierID'].'">'.$temprow['InsuranceCarrier'].'</option>'; } } if ($rowCounter > 1) { echo '</select>'; } ?> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="AgencyID">* Agency Name:</label> </div> <div class="FormInput"> <? $AgenciesResult = mysql_query("SELECT AgenciesAgents.AgencyID, Agencies.AgencyName FROM AgenciesAgents LEFT JOIN Agencies ON AgenciesAgents.AgencyID = Agencies.AgencyID WHERE AgenciesAgents.AgentID = '$AgentID'") or die(mysql_error()); $rowCounter = mysql_num_rows($AgenciesResult); if ($rowCounter == 0) { echo '<span style="background-color: #C0C0C0; color: red; padding: 2px;">You Are Not Associated With Any Agencies, Please Call ParaMedDirect.<span>'; } if ($rowCounter > 1) { echo '<select id="AgencyID" name="AgencyID">'; echo '<option value=""> ... </option>'; } while ($temprow = mysql_fetch_assoc($AgenciesResult)) { if ($rowCounter == 1) { echo '<input type="hidden" id="AgencyID" name="AgencyID" value="'.$temprow['AgencyID'].'" />'; echo '<input style="color: #515151;" type="text" id="AgencyName" name="AgencyName" value="'.$temprow['AgencyName'].'" size="50" READONLY />'; } if ($rowCounter > 1) { echo '<option value="'.$temprow['AgencyID'].'">'.$temprow['AgencyName'].'</option>'; } } if ($rowCounter > 1) { echo '</select>'; } ?> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="AgentID">* Agent Name:</label> </div> <div class="FormInput"> <input type="hidden" id="AgentID" name="AgentID" value="<? echo $AgentID; ?>" /> <input style="color: #515151;" type="text" id="AgentName" name="AgentName" value="<? echo $AgentName; ?>" READONLY /> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="InsuranceCarrierPolicyNumber"> Policy Number:</label> </div> <div class="FormInput"> <input id="InsuranceCarrierPolicyNumber" name="InsuranceCarrierPolicyNumber" type="text" value="<? echo $InsuranceCarrierPolicyNumber; ?>" /> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketFirstName">* Client Name:</label> </div> <div class="FormInput"> <input id="OrderTicketFirstName" name="OrderTicketFirstName" type="text" value="<? echo $OrderTicketFirstName; ?>" required /> <input id="OrderTicketMiddleName" name="OrderTicketMiddleName" type="text" value="<? echo $OrderTicketMiddleName; ?>" size="1" /> <input id="OrderTicketLastName" name="OrderTicketLastName" type="text" value="<? echo $OrderTicketLastName; ?>" required /> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketAddress">* Address:</label> </div> <div class="FormInput"> <input id="OrderTicketAddress" name="OrderTicketAddress" type="text" value="<? echo $OrderTicketAddress; ?>" required size="50" /> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketCity">* City:</label> </div> <div class="FormInput"> <input id="OrderTicketCity" name="OrderTicketCity" type="text" value="<? echo $OrderTicketCity; ?>" required /> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketState">* State:</label> </div> <div class="FormInput"> <select id="OrderTicketState" name="OrderTicketState"> <option value=""> ... </option> <? $StateResult = mysql_query("SELECT * FROM States WHERE 1"); while ($StateRow = mysql_fetch_assoc($StateResult)) { echo '<option value="'.$StateRow['StateAbbr'].'"'; if ($StateRow['StateAbbr'] == $OrderTicketState){echo ' SELECTED';} elseif ($StateRow['StateAbbr'] == "MO"){echo ' SELECTED';} echo '>'.$StateRow['State'].'</option>'; } ?> </select> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketZipCode">* Zip Code:</label> </div> <div class="FormInput"> <input id="OrderTicketZipCode" name="OrderTicketZipCode" type="text" value="<? echo $OrderTicketZipCode; ?>" pattern="[0-9]{5}" required /> </div> </div> <br /> <div class="FormRow"> <span style="font-weight: 600;">Enter Exam Location if Different from Client Location.</span> </div> <br /> <div class="FormRow"> <div class="FormLabel" style="padding-left: 15px;"> <label for="OrderTicketExamLocation">Exam Location:</label> </div> <div class="FormInput"> <select id="OrderTicketExamLocation" name="OrderTicketExamLocation" onchange="ShowHide()"> <? $ExamLocationResult = mysql_query("SELECT * FROM ExamLocations"); while ($ExamLocationRow = mysql_fetch_assoc($ExamLocationResult)) { echo '<option value="'.$ExamLocationRow['ExamLocation'].'"'; if ($ExamLocationRow['ExamLocation'] == $OrderTicketExamLocation){echo ' SELECTED';} echo '>'.$ExamLocationRow['ExamLocation'].'</option>'; } ?> </select> </div> </div> <br /> <div class="show_hide"> <div class="FormLabel" style="padding-left: 15px;"> <label for="OrderTicketExamLocationAddress">Exam Location Address:</label> </div> <div class="FormInput"> <input id="OrderTicketExamLocationAddress" name="OrderTicketExamLocationAddress" type="text" value="<? echo $OrderTicketExamLocationAddress; ?>" size="50" /> </div> </div> <br /> <div class="show_hide"> <div class="FormLabel" style="padding-left: 15px;"> <label for="OrderTicketExamLocationCity">Exam Location City:</label> </div> <div class="FormInput"> <input id="OrderTicketExamLocationCity" name="OrderTicketExamLocationCity" type="text" value="<? echo $OrderTicketExamLocationCity; ?>" /> </div> </div> <br /> <div class="show_hide"> <div class="FormLabel" style="padding-left: 15px;"> <label for="OrderTicketExamLocationState">Exam Location State:</label> </div> <div class="FormInput"> <select id="OrderTicketExamLocationState" name="OrderTicketExamLocationState"> <option value=""> ... </option> <? $StateResult = mysql_query("SELECT * FROM States"); while ($StateRow = mysql_fetch_assoc($StateResult)) { echo '<option value="'.$StateRow['StateAbbr'].'"'; if ($StateRow['StateAbbr'] == $OrderTicketExamLocationState){echo ' SELECTED';} elseif ($StateRow['StateAbbr'] == "MO"){echo ' SELECTED';} echo '>'.$StateRow['State'].'</option>'; } ?> </select> </div> </div> <br /> <div class="show_hide"> <div class="FormLabel" style="padding-left: 15px;"> <label for="OrderTicketExamLocationZipCode">Exam Location Zip Code:</label> </div> <div class="FormInput"> <input id="OrderTicketExamLocationZipCode" name="OrderTicketExamLocationZipCode" type="text" value="<? echo $OrderTicketExamLocationZipCode; ?>" pattern="[0-9]{5}" /> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketHomePhone">* Home Phone:</label> </div> <div class="FormInput"> <input id="OrderTicketHomePhone" name="OrderTicketHomePhone" type="tel" value="<? echo formatPhone($OrderTicketHomePhone); ?>" required /> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketWorkPhone"> Work Phone:</label> </div> <div class="FormInput"> <input id="OrderTicketWorkPhone" name="OrderTicketWorkPhone" type="tel" value="<? echo formatPhone($OrderTicketWorkPhone); ?>" /> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketMobilePhone"> Mobile Phone:</label> </div> <div class="FormInput"> <input id="OrderTicketMobilePhone" name="OrderTicketMobilePhone" type="tel" value="<? echo formatPhone($OrderTicketMobilePhone); ?>" /> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketEmailAddress"> Email Address:</label> </div> <div class="FormInput"> <input id="OrderTicketEmailAddress" name="OrderTicketEmailAddress" type="email" size="50" value="<? echo $OrderTicketEmailAddress; ?>" /> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketDOBMonth">* Date of Birth:</label> </div> <div class="FormInput"> <select id="OrderTicketDOBMonth" name="OrderTicketDOBMonth"> <option value=""> ... </option> <? for ($i=1;$i<13;$i++) { $i = sprintf('%02d', $i); echo '<option value="'.$i.'"'; if ($i == $OrderTicketDOBMonth) {echo ' SELECTED';} echo '>'.$i.'</option>'; } ?> </select> <select id="OrderTicketDOBDay" name="OrderTicketDOBDay"> <option value=""> ... </option> <? for ($i=1;$i<32;$i++) { $i = sprintf('%02d', $i); echo '<option value="'.$i.'"'; if ($i == $OrderTicketDOBDay) {echo ' SELECTED';} echo '>'.$i.'</option>'; } ?> </select> <select id="OrderTicketDOBYear" name="OrderTicketDOBYear"> <option value=""> ... </option> <? $thisYear = date('Y'); for ($i=1900;$i<$thisYear;$i++) { echo '<option value="'.$i.'"'; if ($i == $OrderTicketDOBYear){echo ' SELECTED';} echo '>'.$i.'</option>'; } ?> </select> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketGender">* Gender:</label> </div> <div class="FormInput"> <select id="OrderTicketGender" name="OrderTicketGender"> <option value=""> ... </option> <option value="Male" <? if ($OrderTicketGender == "Male"){echo ' SELECTED';} ?>>Male</option> <option value="Female" <? if ($OrderTicketGender == "Female"){echo ' SELECTED';} ?>>Female</option> </select> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketSmoker">* Tobacco User:</label> </div> <div class="FormInput"> <select id="OrderTicketSmoker" name="OrderTicketSmoker"> <option value=""> ... </option> <option value="Yes" <? if ($OrderTicketSmoker == "Yes"){echo ' SELECTED';} ?>>Yes</option> <option value="No" <? if ($OrderTicketSmoker == "No"){echo ' SELECTED';} ?>>No</option> <option value="NA" <? if ($OrderTicketSmoker == "NA"){echo ' SELECTED';} ?>>Not Applicable</option> </select> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketPolicyType">* Policy Type:</label> </div> <div class="FormInput"> <select id="OrderTicketPolicyType" name="OrderTicketPolicyType"> <option value=""> ... </option> <option value="LifeTerm" <? if ($OrderTicketPolicyType == "LifeTerm"){echo ' SELECTED';} ?>>Life (term)</option> <option value="LifeVariable" <? if ($OrderTicketPolicyType == "LifeVariable"){echo ' SELECTED';} ?>>Life (variable)</option> <option value="Disability" <? if ($OrderTicketPolicyType == "Disability"){echo ' SELECTED';} ?>>Disability</option> <option value="Health" <? if ($OrderTicketPolicyType == "Health"){echo ' SELECTED';} ?>>Health</option> <option value="LTC" <? if ($OrderTicketPolicyType == "LTC"){echo ' SELECTED';} ?>>LTC</option> </select> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketPolicyAmount">* Policy Amount:</label> </div> <div class="FormInput"> <input id="OrderTicketPolicyAmount" name="OrderTicketPolicyAmount" type="text" value="<? if ($OrderTicketPolicyAmount != 0) echo number_format($OrderTicketPolicyAmount, 2); ?>" required /> </div> </div> <br /> <div class="FormRow"> <div class="FormLabel"> <label for="OrderTicketSpecialInstructions"> Special Instructions:</label> </div> <div class="FormInput"> <textarea id="OrderTicketSpecialInstructions" name="OrderTicketSpecialInstructions" cols="40" rows="7"><? echo $OrderTicketSpecialInstructions; ?></textarea> </div> </div> <br /> <div class="FormRow"> <div class="FormSubmit"> <input id="submit" type="submit" value="Submit" /> </div> </div> <br /> </fieldset> <div id="sitesealdiv"> <span id="siteseal"><script type="text/javascript" src="https://seal.godaddy.com/getSeal?sealID=nezI8DdJpwJdyKY47vVrSgFuL1UYVfwDggv4JN4ykS5AumDDidYzrl"></script></span> </div> </form> </div> </body> </html>
  24. Disclaimer: This is my first attempt at doing anything with php, which might be overkill for what's required. Many of the pages of our website have one or more products with multiple selections (drop-down lists). Quite a few orders come in without a selection for one of the critical choices, which necessitates contacting the customer and waiting for a reply. A script which validates required fields could make things run much more smoothly for everyone. I've downloaded such a script and attempted to validate just one list (outside color) but have been unable to get the validation to work. Any guidance will be much appreciated. The files in question are attached for convenience. formvalidator.php 111-php-test.html
  25. I am using Joomla2.5.14 and I want to add some more server side validation like: a) Please enter your email address. (Outline email address box in red). b) Your email address is not registered with Us. (Outline email address box in red). c) Your email address is invalid. (For invalid email address which is different from registered email address - Outline email address box in red). d) Please enter your password. (Outline password box in red). e) Your password is incorrect. (Outline password box in red). in Joomla login page. For my project I have added "awoelogin" to login with email address. Can somebody guide me where to apply changes in Joomla files. I want to show error like this style (http://docs.joomla.org/Display_error_me ... nd_notices). Currently I am getting only one error. (Check my attachment) Thanks
  • 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.