Login   Register  
PHP Classes
elePHPant
Icontem

File: Example_simple.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Edoardo  >  PHP Form To DB  >  Example_simple.php  >  Download  
File: Example_simple.php
Role: Example script
Content type: text/plain
Description: Example1
Class: PHP Form To DB
Validate form submission and save to MySQL records
Author: By
Last change:
Date: 1 year ago
Size: 589 bytes
 

Contents

Class file image Download
<?php

//PostToDb.class.php

/* Example: without validating */


include_once('FormToDb.class.php');

//Incoming five vars: $_POST['name'], $_POST['email'], $_POST['message'], $_POST['checkbox_name'], $_POST['submit_req']

if( isset($_POST['submit_req']) )
{
    
$object = new FormToDb(_DB_HOST__DB_USER__DB_PASSWORD__DB_NAME_'my_table_name');
        
    
//...ignore these post variables
    
$object->toIgnore = array('submit_req''checkbox_name');

    
//...then cycle and save
    
$object->getFromPost($_POST);
    if(
$object->getErrors() == FALSE);
        
$object->save();
}


?>