PHP Classes

File: help.txt

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  Classes of Andrea Bersi  >  Forms generator for MYSQL  >  help.txt  >  Download  
File: help.txt
Role: Documentation
Content type: text/plain
Description: help file
Class: Forms generator for MYSQL
Generate forms to edit MySQL table records
Author: By
Last change:
Date: 8 years ago
Size: 3,592 bytes


Class file image Download
For use the class it is necessary to:
1) create a tree as
    |       |--template.tpl
    |       |--template2.txt
    |       |--template3.tpl
    |       |--arial.ttf  (NB: this file in not in the package)
    |       |--calendar.core.js
    |       |--form.class.php
    |       |--db.conf.php
    |       |--captcha_xxx_124.php
    |       |--captcha.class.php
    NB: the file arial.ttf is not in the package. You need to copy from your font directory.

2) edit the file /class/db.conf.php and insert yor data for access to mysql database server
3) launch the db.sql: the script create the table example.
4) open in your webserver (i.e.:localhost) the file index.

The script work with this features:
if you call a page withut a querystring, the code create a new record in the table you set.
If you call the page with a querystring (name of the key field and your value, example index.php?id=1) the cpde update the value of the selected record

For build a query you need
//insert the db code

//insert the class code

//create instance
$Modulo = new Form();

//set the table for work

//set the name of the form

//set the html code after the label

//activate the javascript validation (client side)

//set the value of the field and if the field is required (this feature with the string Needed as last argument)
$Modulo->labelField("note","Notes","Needed") ;

.... for each field

//set up regular expressions for field validation
$Modulo->registerValidation("required",".+","The field is needed");

.... for each method you want

//apply the validation method to the fields: in this example you want to validate the field note, using the method named "required" and if the validation not suces you print a text as you set in the last argument
$Modulo->validatejava("regExp","note","required","Notes: The field is needed!");

..... for each field you want

//this method load the values (Don't modify)

//this method perform the insert/update in the db ONLY if the server validation is succes

//if not any error you get a success and you work any other code: a echo message or you send an mail 
if ($Modulo->success)
    echo "OK";//code if the success insert
    mail (......);

//add the input html field with the add_campi method
				"val"=> $campo['note'],
				"cols"=>"80")) ;
// THE METHOD require 3 argument: the first is the name of the text to replace in the template file
// the second is the type of HTML field you want (see the documentation class for alla forms input);
// the last argument is an array: the name, the value of the field is created (see the example)

.... for each html input you want

//add a string to the template to replace the tag named pippo
$Modulo->add_php("pippo","This is a test string");

//finally create the form with the render method: the name of the template is needed