PHP Classes

File: example.php

Recommend this page to a friend!
  Packages of Andres Dario Gutierrez Poveda   Forms class   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example
Class: Forms class
Create HTML forms to submit MySQL table records
Author: By
Last change: New way to use the AddJavas function.
Date: 22 years ago
Size: 1,585 bytes
 

Contents

Class file image Download
<?php
      include('Forms.class.php');

      $contratolink = mysql_connect($host,$username,$password);
      $contratodb = mysql_select_db($db);
      $contrato = new Forms($contratolink,$contratodb,$tablename,1);
      $contrato->setPrimaryKey("id");

      //call submit method if form has been submitted
      if(isset($_POST['submit'])){ 
            $contrato->submitForm();     
      }else{
        //retrieve a record for update if GET var set
        if(isset($_GET['id']))
            $contrato->getRecord($_GET['id']);

        //hide primary key field, force a few field types
        $contrato->hideField("id");

        //order of the fields
        $contrato->orderField(array("cognome","nome"));

        //get data pairs from another table
        $contrato->normalizedField("fk_estadocontratoid","estadocontrato","id","nombre","1","nombre ASC");

        //set custom field labels
        $contrato->labelFields( array("nome","cognome "),array("Nome","Cog Nome "));

    //Choose the methods to validate.
    $validaciones['isEmailAddr'] = 1;
    $validaciones['validRequired'] = 1;
    $validaciones['allDigits'] = 1;
    $validaciones['allDigitss'] = 1;
    $validaciones['inValidCharSet'] = 1;    
    $validaciones['validNum'] = 1;
    $validaciones['validInt'] = 1;    
    $validaciones['validDate'] = 1;
    $validaciones['validDatetime'] = 1;    
    $validaciones['validForm'] = 1;

        //output form       
        echo $contrato->AddJavas($validaciones);                                           

        $contrato->printForm("");

      }

?>