PHP - Schema Validation
Hi, here is my validateXML function, it checks first if an XML file is well-formed and result $result is true, then if well-formed and schema provided, it does further check to see if schema validated and result $result returns true too (using php core function: schemaValidate(string $schemaFileName), so my let's say I use stuff.xml and houses.xsd, so even if stuff.xml is well formed, and the function goes to evaluate houses.xsd(assume also validated), then the $result of true doesn't really indicate that the well formed stuff.xml is also schema validated since schemaValidate only checks if a schema itself is validated, BUT how does it link the validated schema to the well-formed stuff.xml.
In short, I am saying I can pass a wellformed xml file that with a validated schema file BUT the two may be totally different. Here is the function: Code: [Select] </php public function validateXML($xmlFilename, $xmlSchema=null) { $result = false; //which line you don't understand $dom = new DOMDocument(); if ( $dom->load($xmlFilename) || $dom->loadXML($xmlFilename))//so this tests if it is well formed?yes { //and if false, $result is false //the xml is well-form, now test schema $result = true; if ( $xmlSchema ) // if we don't pass schema , mean we don't need to test the shcme, the validate will return true still { $result = $dom->schemaValidate($xmlSchema);//returns true on success } } //error occurrs, if there is not erro, this code will not run, because errors is empty array $errors = libxml_get_errors(); //stores each line as array elem foreach ($errors as $error) { print $this->showLibXMLErrors($error); } libxml_clear_errors(); return $result;//1 is TRUE, 0 is FALSE } ?> I'd appreciate any help! Similar TutorialsXSD
<?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. This is a more general schema design question as opposed to specific queries.
I'm designing a database which tracks the production status of 2 (and in the future maybe 2 or so more) completely different products. So let's call these products productA and productB. I have a page where the user can see the progress of either of the products.
This concerns these 3 tables:
productA(id, order_id, status)
productB(id, order_id, status)
production_status(id, status, ordering, type)
The status is number based PER product so that it can move up a chain of statusses in its production process. So if a product is in status with ordering 10 it's done (assuming there are 10 production steps). So at ordering 1 its production just started. The status field contains at which production step it is which will be visible on the page. Now this is where i get stuck. I somehow have to differentiate between statusses so I know which statusses belong to which product. I put type in so it could filter for either productA or productB, but also for future products. But working with strings is not such a smart idea I think. I could make 2 more seperate tables, but I'm not sure how well that would scale.
So my question is what a good approach would be.
Some background info: I'm building a Joomla component for a small company. Like I said they want to track the status of these products. Every time a production person unpublishes said item on its production view inside the component, the product moves to the next status
Edited by Ortix, 13 May 2014 - 04:14 AM. Has anyone got any script or refence to a tut where i can find a script that compares two mysql database (current) and outdated db and then takes the current db and updates the outdated one to match accordingly. Thanks If you are using Vertabelo for creating database models and you access your database with Propel library, you'll find the following instructions useful. im looking to validate an email address before it gets sent to mysql database currently my code checks if an email address is present and if an email address already exists how do you check to see if an address contains a . and a @ symbol? Code: [Select] if($email == '') { $errmsg_arr[] = 'Email is missing'; $errflag = true; } if($email != '') { $qry = "SELECT * FROM users WHERE email='$email'"; $result = mysql_query($qry); if($result) { if(mysql_num_rows($result) > 0) { $errmsg_arr[] = 'Email address already in use'; $errflag = true; } @mysql_free_result($result); } else { die("Query failed"); } } Thanks in advance i am using the following to validate a submission form. when i take this validation script out, the php script works fine, however when i use it it redirects to index.html as if their was an error.... please can somebody help, ive tried and cannot see the problem? $fname = $_POST['firstname']; $lname = $_POST['lastname']; $add1 = $_POST['add1']; $add2 = $_POST['add2']; $city = $_POST['city']; $county = $_POST['county']; $country = $_POST['country']; $postcode = $_POST['postcode']; $email1 = $_POST['email1']; $email2 = $_POST['email2']; $mobile = $_POST['mobile']; $home = $_POST['home']; $time = $_POST['time']; $answer = $_POST['answer']; $job = $_POST['job']; $ip = $_SERVER['REMOTE_ADDR']; // validation $validationOK=true; if (Trim($fname)=="") $validationOK=false; if (Trim($lname)=="") $validationOK=false; if (Trim($add1)=="") $validationOK=false; if (Trim($city)=="") $validationOK=false; if (Trim($county)=="") $validationOK=false; if (Trim($country)=="") $validationOK=false; if (Trim($postcode)=="") $validationOK=false; if (Trim($email1)=="") $validationOK=false; if (Trim($email2)!=="$email1") $validationOK=false; if (Trim($mobile)=="") $validationOK=false; if (Trim($time)=="") $validationOK=false; if (Trim($answer)!=="34") $validationOK=false; if (Trim($job)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=index.html\">"; exit; } So Im in the weird place where my age validation is not working, any ideas: $dob = strtotime($_POST['dob']); //855993600 Feb 15th 1997 $age_req = strtotime('-13 year', $dob); //445680000 Feb 15th 1984 $time = time(); //1292007621 if ($time < $age_req){} Hi, I have a mistmatched tag <messagesss></message> BUT it still displays "Validated XML!" BUT then proceeds to the else that outputs each XML error! here is the XML: Code: [Select] <?xml version="1.0" encoding="utf-8"?> <email> <messagesss> <to> <toFirstName>Tove</toFirstName> <toLastName toType="common" style="swag">Smith</toLastName> </to> <from><fromdd/> <fromFirstName>Jani</fromFirstName> <fromLastName fromType="unique">Dravison</fromLastName> </from> </message> </email> Code: [Select] <?php $dom=new DOMDocument(); $dom->load("emailSimple.xml"); $isValidated=false; $dom->formatOutput = true; $dom->saveXML(); $errors=libxml_get_errors();//Returns array where each XML file line is an elem if(!file_exists("emailSimple.xml")) print "no such file!"; else if(strlen(file_get_contents("emailSimple.xml"))==0) print "File is empty!"; else if($dom) {//IF file exists and has content if(empty($errors)) print "Validated XML!";//isValidated=true so now shred! else { //CHECK if current XML file is Well-formed foreach($errors AS $error) {//FOR EACH ERROR OF CURRENT XML FILE TO CHECK echo "Error Code: ".$error->code."<br />"; echo "Error message: ".$error->message; //Column is the end of the line where error is echo "line".$error->line.", column".$error->column."<br />"; echo "----------------------------------------------<br /><br />"; } } libxml_clear_errors(); } ?> I'm looking for a bit of help introducing some validation into my "contact us" page. I'm looking to make the user have to enter an email address into textbox And something into the Enquiry box. My 2 files are below: contact-us.shtml Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Byrne Computing Services</title> <link href="styles.css" rel="stylesheet" type="text/css" /> <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script> <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="inc/jquery.js"></script> <script type="text/javascript" src="inc/easySlider.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#slider").easySlider(); }); </script> </head> <body> <div id="wrapper"> <!--#include file="inc_header.html" --> <!--#include file="inc_scrollingimages.html" --> <div id="boxesholder"> <!--#include file="inc_specials.html" --> <div id="main"> <div id="mainheader"> Contact Us</div> <div id="maincontent2"> <h2>Fill in the form below and we will contact you shortly.</h2> <p><img src="images/binarycode.jpg" alt="Binary Code" width="167" height="600" class="images" /><form id="form1" name="form1" method="post" action="mailer.php?mail=1"> <strong>Name: </strong><br /> <input name="name" type="text" class="formsingle" id="name" /> <br /> <br /> <strong>Email:</strong><br /> <input name="email" type="text" class="formsingle" id="emailaddress" /> <br /> <br /> <strong>Interested in:</strong><br /> <table border="0" cellspacing="0" cellpadding="0" class="table"> <tr> <td class="interestedin"><strong>Computer Repair</strong></td> <td class="interestedin"><strong>Console Repair</strong></td> <td class="interestedin"><strong>Other Services</strong></td> </tr> <tr> <td class="interestedin"> <input name="virusandmalwareremoval" type="checkbox" class="formcheckbox" id="virusandmalwareremoval" value="virusandmalwareremoval" /> <label for="virusandmalwareremoval">Virus and Malware Removal</label> </td> <td class="interestedin"> <input name="xbox360drivereplacement" type="checkbox" class="formcheckbox" id="xbox360drivereplacement" value="xbox360drivereplacement" /> <label for="ps3drivereplacement">Xbox 360 Drive Replacement</label> </td> <td class="interestedin"> <input name="databackup" type="checkbox" class="formcheckbox" id="databackup" value="databackup" /> <label for="databackup">Data Backup</label> </td> </tr> <tr> <td class="interestedin"> <input name="fullservice" type="checkbox" class="formcheckbox" id="fullservice" value="fullservice" /> <label for="fullservice">Full Service</label> </td> <td class="interestedin"> <input name="xbox360laserreplacement" type="checkbox" class="formcheckbox" id="xbox360laserreplacement" value="xbox360laserreplacement" /> <label for="ps3laserreplacement">Xbox 360 Laser Replacement</label> </td> <td class="interestedin"> <input name="websites" type="checkbox" class="formcheckbox" id="websites" value="websites" /> <label for="websites">Web Design</label> </td> </tr> <tr> <td class="interestedin"> <input name="quickfix" type="checkbox" class="formcheckbox" id="quickfix" value="quickfix" /> <label for="quickfix">Quick Fix</label> </td> <td class="interestedin"> <input name="xbox360rrodrepair" type="checkbox" class="formcheckbox" id="xbox360rrodrepair" value="xbox360rrodrepair" /> <label for="ps3ylodrepair">Xbox 360 RROD Repair</label> </td> <td class="interestedin"> <input name="datarecovery" type="checkbox" class="formcheckbox" id="datarecovery" value="datarecovery" /> <label for="datarecovery">Data Recovery</label> </td> </tr> <tr> <td class="interestedin"> <input name="upgrades" type="checkbox" class="formcheckbox" id="upgrades" value="upgrades" /> <label for="upgrades">Upgrades</label> </td> <td class="interestedin"><input name="ps3drivereplacement" type="checkbox" class="formcheckbox" id="ps3drivereplacement" value="ps3drivereplacement" /> <label for="ps3drivereplacement">PS3 Drive Replacement</label></td> <td class="interestedin"> <input name="networkinstallation" type="checkbox" class="formcheckbox" id="networkinstallation" value="networkinstallation" /> <label for="networkinstallation">Network Installation</label> </td> </tr> <tr> <td> </td> <td class="interestedin"><input name="ps3laserreplacement" type="checkbox" class="formcheckbox" id="ps3laserreplacement" value="ps3laserreplacement" /> PS3 <label for="ps3laserreplacement"> Laser Replacement</label></td> <td class="interestedin"> <input name="mobilephoneissues" type="checkbox" class="formcheckbox" id="mobilephoneissues" value="mobilephoneissues" /> <label for="mobilephoneissues">Mobile Phone Issues</label> </td> </tr> <tr> <td> </td> <td class="interestedin"><input name="ps3ylodrepair" type="checkbox" class="formcheckbox" id="ps3ylodrepair" value="ps3ylodrepair" /> <label for="ps3ylodrepair">PS3 YLOD Repair</label></td> <td class="interestedin"> <input name="emailconfiguration" type="checkbox" class="formcheckbox" id="emailconfiguration" value="emailconfiguration" /> <label for="emailconfiguration">Email Configuration</label></td> </tr> </table> <br /> <strong>Enquiry: </strong><br /> <textarea name="enquiry" class="formmulti" id="enquiry"></textarea> <br /> <br /> <input type="submit" name="button" id="button" value="Submit" /> </form> </p> <p><br /> </p> </div> </div> </div> <!--#include file="inc_offers.html" --> <!--#include file="inc_footer.html" --> </body> </html> Mailer.php Code: [Select] <?php function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; } if (isset($_REQUEST['name'])) { $name = $_REQUEST['name'] ; $email = $_REQUEST['email'] ; $enquiry = $_REQUEST['enquiry'] ; if (isset($_REQUEST['virusandmalwareremoval'])){ $virusandmalwareremoval = $_REQUEST['virusandmalwareremoval'] . "\n"; } else { $virusandmalwareremoval = ""; } if (isset($_REQUEST['fullservice'])){ $fullservice = $_REQUEST['fullservice'] . "\n"; } else { $fullservice = ""; } if (isset($_REQUEST['quickfix'])){ $quickfix = $_REQUEST['quickfix'] . "\n"; } else { $quickfix = ""; } if (isset($_REQUEST['upgrades'])){ $upgrades = $_REQUEST['upgrades'] . "\n"; } else { $upgrades = ""; } if (isset($_REQUEST['xbox360drivereplacement'])){ $xbox360drivereplacement = $_REQUEST['xbox360drivereplacement'] . "\n"; } else { $xbox360drivereplacement = ""; } if (isset($_REQUEST['xbox360laserreplacement'])){ $xbox360laserreplacement = $_REQUEST['xbox360laserreplacement'] . "\n"; } else { $xbox360laserreplacement = ""; } if (isset($_REQUEST['xbox360rrodrepair'])){ $xbox360rrodrepair = $_REQUEST['xbox360rrodrepair'] . "\n"; } else { $xbox360rrodrepair = ""; } if (isset($_REQUEST['ps3drivereplacement'])){ $ps3drivereplacement = $_REQUEST['ps3drivereplacement'] . "\n"; } else { $ps3drivereplacement = ""; } if (isset($_REQUEST['ps3laserreplacement'])){ $ps3laserreplacement = $_REQUEST['ps3laserreplacement'] . "\n"; } else { $ps3laserreplacement = ""; } if (isset($_REQUEST['ps3ylodrepair'])){ $ps3ylodrepair = $_REQUEST['ps3ylodrepair'] . "\n"; } else { $ps3ylodrepair = ""; } if (isset($_REQUEST['databackup'])){ $databackup = $_REQUEST['databackup'] . "\n"; } else { $databackup = ""; } if (isset($_REQUEST['websites'])){ $websites = $_REQUEST['websites'] . "\n"; } else { $websites = ""; } if (isset($_REQUEST['datarecovery'])){ $datarecovery = $_REQUEST['datarecovery'] . "\n"; } else { $datarecovery = ""; } if (isset($_REQUEST['networkinstallation'])){ $networkinstallation = $_REQUEST['networkinstallation'] . "\n"; } else { $networkinstallation = ""; } if (isset($_REQUEST['mobilephoneissues'])){ $mobilephoneissues = $_REQUEST['mobilephoneissues'] . "\n"; } else { $mobilephoneissues = ""; } if (isset($_REQUEST['emailconfiguration'])){ $emailconfiguration = $_REQUEST['emailconfiguration'] . "\n"; } else { $emailconfiguration = ""; } if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) { header( "Location: http://www.parkersmedia.com/byrne" ); } $mailcontent = "Name: ".$name; $mailcontent.= "\n\nEmail: ".$email; $mailcontent.= "\n\nInterested in: \n". $virusandmalwareremoval . $fullservice . $quickfix . $upgrades . $xbox360drivereplacement . $xbox360laserreplacement . $xbox360rrodrepair . $ps3drivereplacement . $ps3laserreplacement . $ps3ylodrepair . $databackup . $websites . $datarecovery . $networkinstallation . $mobilephoneissues . $emailconfiguration; $mailcontent.= "\n\nEnquiry: " . $enquiry; mail( "info@byrnecomputingservices.ie", "Enquiry from Byrne Computing Services", "$mailcontent", "From: $name <$email>" ); } header( "Location: http://www.parkersmedia.com/byrne/thankyou.shtml" ); ?> Any help on this would be great! Hello I have a textbox and a input button which will insert a mysql record, however i need to validate that textbox if its empty it shouldnt allow that button to insert any record but show a popup error. my script : <script Language="JavaScript"> function Blank_TextField_Validator() { // Check the value of the element named text_name // from the form named text_form if (frmContact.id.value == "") { // If null display and alert box alert("Please fill in the text field."); // Place the cursor on the field for revision frmContact.id.focus(); // return false to stop further processing return (false); } // If text_name is not null continue processing return (true); } </script>Form : <form name="frmContact" id="frmContact" method="POST" action="index.php" onsubmit="return Blank_TextField_Validator()">however its not validating or showing any error. any help? Edited by sam20e, 11 November 2014 - 10:31 AM. Hi there, I am working on getting my php form validation working. I just learned why mine wasn't working and it was because I had a header(location) in the middle of the html doc. The reason I had it there was because the code I am using is placed where I want the error to show. Here is the code I am using for this part. I only have one field being validated at the moment. Code: [Select] <? session_start(); if ($_POST['submit']) { $_SESSION['City'] = $_POST['City']; $errors = ""; if(!$_SESSION['City']){ $errors = $errors . "Please enter your city<br>"; } if ($errors != "") { echo "Please check the following errors:<br>"; echo $errors; } else { header("Location: nextpage.php"); } } ?> My question is: What way would you reorganize this (scrapy) validation to where I can redirect my user to a new page when there is no error value? The form page submits to itself with POST. Thanks for your help. I have a form validation script which is written in php.. I want to add a validation (in registration form) that if the desired username contains either admin or owner keyword user will have to change his user name.. I made the following code but it does not work.. if(strpos($user_name, "admin")>=0 || strpos($user_name, "moderator")>=0 || strpos($user_name, "owner")>=0) { $error=$error."You are not allowed to take such Username<br>"; $bool=false; } In this code i am not able to enter any username.. And if i change >= to > then "admin123" username is going to be valid... I am troubled .... help me out guyzzz -pranshu.a.11@gmail.com I need to validate first name, last name, street, suburb, postcode, email, status and date of birth. I tried to do this validation but gave me heaps of error and I messed up more. Spoiler if (empty($firstname)) {$errors[] =" First Name Can not be Empty <br> ";} if (empty($lastname)) {$errors[] =" Last Name Can not be Empty <br> ";} if (empty($street)) {$errors[] =" Street Can not be Empty <br> ";} if (empty($suburb)) {$errors[] =" Suburb Can not be Empty <br> ";} if (empty($postcode)) {$errors[] =" Postcode Can not be Empty <br> ";} // elseif (!is_numeric($postcode)) {$errors[] =" Postcode must be numeric ";} elseif(!preg_match("/\^\(\[0\-9\]\{5\}\(\[\-\\s\]\?\[0\-9\]\{4\}\)\?\)\$/", $postcode)) {$errors[] =" Please enter a valid post number <br> ";} if( !preg_match("/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/i", $myemail) ) {$errors[] =" You have entered and invalid email address <br> ";} if (empty($DOB)) {$errors[] =" Date only <br> ";} Chaps, as a beginner developing his first web app in PHP, I have done fairly well.
However, I am struggling when it comes to validation.
I have written different ELSEIF statements as seen below which would actually carry out the validation itself.
// First name must be filled and in correct format. if(empty($FirstName)) { $errFirstName = '<p class="errText"> Please enter a value</p>'; echo $errFirstName; }elseif(!preg_match('/^[a-z]+$/i',$FirstName)){ $errFirstName = '<p class="errText">Name may not start with a dash. Letters, spaces and dashes are accepted.</p>'; echo $errFirstName; }The problem is that I do not know how to make them "pop up" when the user makes a mistake. I have a form in addteam.php seen below: <form action="pushteam.php" method="post"> <p>Team name: <input type="text" name="TeamName" /></p> <p>Description: </p> <p><textarea name="Description" rows="4" cols="50">Add your description here.</textarea></p> <p><input type="submit"/></p> </form>And a pushplayer.php script that pushes it to a mysql database: // Get values from form $TeamName=$_POST['TeamName']; $Description=$_POST['Description']; } // Insert data into database $sql="INSERT INTO Teams(TeamName, Description)VALUES('$TeamName', '$Description')"; $result=mysql_query($sql); //If successful return to success.php else print error if($result){ header( 'Location: success.php'); } else { header( 'Location: failure.php'); }The scripts function properly. I would really appreciate if someone could guide me in the right direction here. Make the error pop up and make sure the data is not input. At the moment, if I add my ELSEIF statements, it will carry on and insert the data anyway and redirect me. Thanks Hi, Im making a form that contains 3 textboxes.. now i want my textboxes to contain only letters.. i used is_numeric for the validation but when i put' like.. "JUSHIRO1" my code will still accept it. can someone help me make a code that will validate my textbox to only accept letters. and one more.. when the user input in the textbox with a number a popup box will appear. I am really new to using php validation, I think I may be on to what I am looking for but not very sure. I am trying to validate my form fields just incase someone forgets (name, subject, message, and email). Here is what I have so far. I was looking at an example on how to validate a phone number. Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Contact</title> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <?php $first_name=$_POST['name']; $email_address=$_POST['email']; $subject=$_POST['subject']; $message=$_POST['text']; if(isset($_GET['submit'])) { if(preg_match("/^\(([ $_GET['email']) != ) { echo "The email field was invalid<BR>"; } else if(isset($_GET['submit'])) { if(preg_match("/^\(([ $_GET['name']) != "") { echo "The name field was invalid<BR>"; } else if(isset($_GET['submit'])) { if(preg_match("/^\(([ $_GET['subject']) != "") { echo "The subject field was invalid<BR>"; } else { mail("myemailaddress@gmail.com","Subject: $subject", $message, "From: $first_name <$email_address>"); echo "Thank you for using our mail form.<br/>"; echo "Your email has been sent."; } ?> </body> </html> Hi, There is this project 'District Collector Office-Information integration' that computerizes the citizen facility center. In the system citizens can apply for birth certificates,marriage certificate , obtain ration cards among other functionalists online.so far my system can generate birth and marriage certificates but i totally have no idea on how to validate the same.at what conditions is one illegible to obtain a marriage cert?,supposing one has more than one wife?,what limits one from applying for more than one document? when is one illegible to obtain a birth cert.? conditions limiting application of more than one birth cert ? Thanx. Regards cornelius Hi, I am searching for a basic, easy to implement php form validation script that checks if the user has filled out a field, if they havent to tell them so. i have tried basic if statements but it refreshes the page and all the other fields that were filled in are clear. Anyone know of any tricks or scripts that are good? Thanks in advance. Hi all, I've been struggling to develop a robust image upload validation script. I have an area on my site where users can upload a profile picture into a directory so, to keep it clean and safe here is what I want: 1) Script must work in IE and Firefox 2) Script must only allow image files to be uploaded 3) Images shouldn't be unreasonable in size say 4mb max. Currently i'm using this Code: [Select] if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 40000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { if (file_exists("profiles/images/$filegif")) { unlink("profiles/images/$filegif"); } if (file_exists("profiles/images/$filejpeg")) { unlink("profiles/images/$filejpeg"); } move_uploaded_file($_FILES["file"]["tmp_name"], "profiles/images/" .$name); } //.... send me email to let me view picture ....// } else { echo "Invalid file - Only Gif or Jpeg files may be uploaded."; ///... send me error message to let me know user having problems .../// } } Some users upload fine (is this browser compatability?), mostly I get alot or error messages though and have to upload manually. Thanks in advance! |