Login   Register  
PHP Classes
elePHPant
Icontem

File: insert_sample.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Ihab Abu Afia  >  basic_db  >  insert_sample.php  >  Download  
File: insert_sample.php
Role: Example script
Content type: text/plain
Description: Insert Example
Class: basic_db
Manipulate MySQL table records programmatically
Author: By
Last change:
Date: 2007-08-21 13:56
Size: 904 bytes
 

Contents

Class file image Download
<?

include('basic_db.php');

if(!
$_POST['submit'])
{
?>
    <form action="<?=$_SERVER['PHP_SELF']?>" method="post" name="account">
    First Name <input name="firstname" type="text" size="25" /><br>
    Last Name <input name="lastname" type="text" size="25" /><br>
    <input name="xxx" type="hidden" value="4" />
    <input name="yyy" type="hidden" value="4" />
    <input name="submit" type="submit" value="Go" />
    </form>
<?
}
else
{
    
$db = new Database;
    
$db->Table_Name('accounts');
    
$db->Fields($HTTP_POST_VARS);
    
$db->doPrint(); // This is for debugging purposes to echo the query, so it's optional.
    
$db->hidden(array('xxx''yyy')); // Use this when only incase you have hidden inputs.
    
$id $db->Insert();

    if(
$id)
    {
        echo 
"Data has been inserted in record # ".$id;
    }
    else
    {
        echo 
"There was an error inserting the data, please check your conncetion information";
    }
}