Login   Register  
PHP Classes
elePHPant
Icontem

File: example1_process.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of sameer shelavale  >  X2Form  >  example1_process.php  >  Download  
File: example1_process.php
Role: Example script
Content type: text/plain
Description: Processing and validating the Quidich form in Example1
Class: X2Form
Show and validate HTML forms defined in XML files
Author: By
Last change: changed file paths as folder structure is not permitted on phpclasses
Date: 2 years ago
Size: 2,110 bytes
 

Contents

Class file image Download
<?php
/****************************************************************************************************
 * Author: Sameer Shelavale
 * Email: sameer@possible.in, samiirds@gmail.com
 * Author website: http://possible.in
 * Phone: +91 9890103122
 * License: AGPL3, You should keep Package name, Class name, Author name, Email and website credits.
 *             http://www.gnu.org/licenses/agpl-3.0.html
 *             For other type of licenses please contact the author.
 * PHP Version: Tested on PHP 5.2.2 & 5.3.10
 * Copyrights (C) 2012 Sameer Shelavale
 * 
 ****************************************************************************************************/

require_once( 'X2Form.php' );
require_once( 
'X2FormElement.php' );
require_once( 
'class.dbhelper.php' );
require_once( 
'class.logger.php' );

$link mysql_connect('localhost''root''');
if (!
$link) {
    die(
'Could not connect: ' mysql_error());
}
$db_selected mysql_select_db('test'$link);
if (!
$db_selected) {
    die (
'Can\'t select database : ' mysql_error());
}


$formObj = new X2Form'DiamondForm''xmlfile''quidich_form.xml'  );

if( 
$_POST['submit'] == "Submit" ){
    
    
$formObj->setFormValues($_POST);
    
$result $formObj->processSubmission$_POST );    
    
    
$formObj->rollBackFileUploads();
    
}


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Diplaying a Form using X2Form</title>
    <link href="style.css" type="text/css" rel="stylesheet">
</head>
<body>
    <div id="container">
        <h1>Example 1: X2Form Form Generator</h1>
        <h3>Displaying form stored in <a href="forms/quidich_form.xml">xml file</a></h3>
        <?php 
        
        
if( $_POST['dump'] ){
            
var_dump$_POST );
        }elseif( 
$result['result'] == 'Success'){
            
var_dump$result );
            
        }else{
            echo 
'<div class="error">'.$result['message'].'<br/>'.$formObj->errorString."</div>";
            echo 
$formObj->render();
        }
         
        
?>
    </div>
    <br/>
    <br/>
</body>
</html>