Login   Register  
PHP Classes
elePHPant
Icontem

File: update_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  >  update_sample.php  >  Download  
File: update_sample.php
Role: Example script
Content type: text/plain
Description: Update Example
Class: basic_db
Manipulate MySQL table records programmatically
Author: By
Last change:
Date: 2007-08-21 13:58
Size: 1,170 bytes
 

Contents

Class file image Download
<?

include('basic_db.php');

?>

<?
if(!$_POST['Update'])
{
?>
<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="user_id" type="hidden" value="11" />
<input name="xxx" type="hidden" value="xxx" />
<input name="yyy" type="hidden" value="www" />
<input name="Update" type="submit" value="Update Data" />
</form>
<?
}
else
{
    
$db = new Database;
    
$db->Table_Name('accounts');
    
$db->Fields($HTTP_POST_VARS);
    
$db->Submit('Update'); // This is only when the Input submit namded anything other than 'submit'
    
$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.
    
$done $db->Update('user_id'); // user_id is to indicate which row you want to update in the table.
    
$xxx $HTTP_POST_VARS;
    
    if(
$done)
    {
        echo 
"your account has been updated";
    }
    else
    {
        echo 
"There was an error updating the data, please check your conncetion information";
    }
}