PHP PROJECT

README.md

Compose, validate and display forms with Bootstrap

This class can compose, validate and display forms with Bootstrap. It can compose and display forms with common fields using Bootstrap to render the forms using a given template in HTML. The class can also validate the submitted form values according to given validation rules. Currently it can validate each form input value as digit, as decimal, as upper and lower alphabetic text, alpha-numeric text, email address, IP address, url, hexadecimal text, float value, a login name, mac address, credit card, safe text, english text, image file, value smaller, larger or equal to a value, non-empty text, date, and matching a regular expression.

Files


NameTypeSizeLast Modified
formClass.php phpfile icon 14467 05 February 2016 08:50:08
form-example.php phpfile icon 1602 05 February 2016 08:50:08
readme.txt textfile icon 1448 05 February 2016 08:50:08
template directory icon 4096 31 March 2017 08:37:28

Source

  1. include 'formClass.php';
  2. $o=new bootstrapformClass;
  3. if(isset($_GET['q']) && $_GET['q'] == 'newmember')
  4. {
  5. /*
  6. Rule
  7. digit 0-9 all char digit
  8. =password2  ("password"=>"=".$password2."|digit|gt:5"  password equal to password2  all char digit  password > 5
  9. decimal  0-9 .  all char digit and .
  10. alphasmall a-z  all a-z small latter  
  11. alphaupper A-Z all A-Z upper letter
  12. alpha  a-zA-z all upper and small letter
  13. alphanum a-zA-z0-9 all upper, small and digit letter
  14. alphaall all chars (a-z) (A-Z) (0-9) (_.-  +)
  15. email email@v23.in
  16. ip 198.168.1.1
  17. url v23.in
  18. hex #882211
  19. float 09900.90
  20. name
  21. mac 99:2a:9c:22:21
  22. creditcard  5231-2211-2211-229a
  23. safetext a-zA-Z0-9 .\-_,!
  24. english
  25. fullurl http(?)://www.yourdomain.com  //https?|ftps?|gopher|telnet|nntp
  26. imagefile  gif|png|jpg|jpeg
  27. lt:  string <= strlen  lt:7
  28. gt: string >= strlen  gt:12
  29. eq: string == strlen eq:10
  30. required
  31. mmddyy date 092215
  32. regx   regx/php/i
  33. // "gt:3|alpha|url|email" ....
  34. */
  35. $datain=array("name"=>"gt:10|digit");
  36.     if($r=$o->_findValid($datain,$_POST)){
  37.     $op['maincontent'] = '<div class="alert alert-danger" role="alert">'.$r.'</div>' . newMember($o,$_POST);
  38.     }
  39.     else{
  40.     $op['maincontent'] = '<div class="alert alert-success" role="alert">Success..</div>';
  41.     }
  42. }
  43. else
  44. $op['maincontent'] = newMember($o);
  45. //--- template ---------
  46. if(is_file("./template/form-template.html")){
  47.             echo $o->render_temp("./template/form-template.html",$op);
  48.     }    

Demo

You can find a demo available here: html form builder

Requirment

  • mySql
  • PHP >= 5.4
  • Apache Server

Contribute

  • Vishv Sahdev

Example

>>

Download