Hello there again
i am still learning on server side validation going through each and every possible post of this forum and through google
any way i will not continue posting here, as everything much clear for me how it works (still i dont know how to use it with chronoform)
what i suggest for the next release of chronoform is following ( max i am sure you already know this 😶 )
Sanitize and Validate Data with PHP FiltersMost people tend to think of data validation as an immensely tedious process where one either:
* Compares the data they want to validate against every possible combination they can think of.
* Tries to find a golden Regular Expression that will match every possible combination.
* A combination of the two.There are obvious problems with the above listed:
* It's absolutely time consuming.
* There is a very high chance of error.Fortunately, beginning with version 5.2, PHP has included a great function called filter_var that takes away the pain of data validation.filter_var In Action
filter_var will do, both, sanitize and validate data. What's the difference between the two?
* Sanitizing will remove any illegal character from the data.
* Validating will determine if the data is in proper form.Note: why sanitize and not just validate? It's possible the user accidentally typed in a wrong character or maybe it was from a bad copy and paste. By sanitizing the data, you take the responsibility of hunting for the mistake off of the user.
How to use filter_var
Using filter_var is incredibly easy. It's simply a PHP function that takes two pieces of data:
* The variable you want to check
* The type of check to use
For example, the below code will remove all HTML tags from a string:
1. $string = "<h1>Hello, World!</h1>";
2. $new_string = filter_var($string, FILTER_SANITIZE_STRING);
3. // $new_string is now "Hello, World!"
$string = "<h1>Hello, World!</h1>";
$new_string = filter_var($string, FILTER_SANITIZE_STRING);
// $new_string is now "Hello, World!"
Here's another example -- this time more difficult. The below code will ensure the value of the variable is a valid IP address:
view plaincopy to clipboardprint?
1. $ip = "127.0.0.1";
2. $valid_ip = filter_var($ip, FILTER_VALIDATE_IP);
3. // $valid_ip is TRUE
4.
5. $ip = "127.0.1.1.1.1";
6. $valid_ip = filter_var($ip, FILTER_VALIDATE_IP);
7. // $valid_ip is FALSE
$ip = "127.0.0.1";
$valid_ip = filter_var($ip, FILTER_VALIDATE_IP);
// $valid_ip is TRUE
$ip = "127.0.1.1.1.1";
$valid_ip = filter_var($ip, FILTER_VALIDATE_IP);
// $valid_ip is FALSE
That's how simple it is to use filter_var. For a complete list of all the rules you can check against, see the end of this tutorial.
Sanitizing Example
Below is a quick example of sanitizing input from two fields: an email field and a home page field. This example will remove any characters that should not occur in either type of data.
1. <?php
2. if (isset($_POST['email'])) {
3. echo filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
4. echo "<br/><br/>";
5. }
6.
7. if (isset($_POST['homepage'])) {
8. echo filter_var($_POST['homepage'], FILTER_SANITIZE_URL);
9. echo "<br/><br/>";
10. }
11. ?>
12.
13. <form name="form1" method="post" action="form-sanitize.php">
14. Email Address: <br/>
15. <input type="text" name="email" value="<?php echo $_POST['email']; ?>" size="50"/> <br/><br/>
16. Home Page: <br/>
17. <input type="text" name="homepage" value="<?php echo $_POST['homepage']; ?>" size="50" /> <br/>
18. <br/>
19. <input type="submit" />
20. </form>
continue reading on arrow-right
http://nettuts.com/tutorials/php/sanitize-and-validate-data-with-php-filters/this is just to help you max and also to help myself and other chronoform user, i & others will really appreciate if you include something like this as built in form validation in next release 🙂
learning all this stuff really hard part for people like me, i am working on my project and really wanted to relay on one component like chronoform, rsform
i have used rsform in past it do have built in server side validation (only alpha & alphanum) that can be enough with some simple forms..
i really liked the chronoform and if you add the validation method it will be the best form component out there 😀
i will leave the validation for my site for a while as i have not finished my project yet, may be in one month i will pm you to have a look 🙂
thanks for your understanding 😀