Login   Register  
PHP Classes
elePHPant
Icontem

File: tpl.set_user.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of marcelo entraigas  >  AMD  >  tpl.set_user.php  >  Download  
File: tpl.set_user.php
Role: Example script
Content type: text/plain
Description: Example - template form
Class: AMD
Add, modify and delete MySQL table records
Author: By
Last change:
Date: 5 years ago
Size: 1,263 bytes
 

Contents

Class file image Download
<?php

    
function get_option($arr_option$selected){
        
$return '';
        foreach (
$arr_option as $key => $value) {
            
$tmp = ($value==$selected)? ' selected' '';
            
$return .= "<option value=\"$key\"$tmp>$value</option>";
        }
        return 
$return;
    }
    
    
$db = new Database();
    
$id intval($_GET['id']);
    
$sql "SELECT * FROM users WHERE user_id = $id LIMIT 1";
    
$arr_user $db->get_row($sql);
    
$arr_type $db->get_enum_values('users','user_type');
?>
<form method="POST" action="index.php">
<input type="hidden" name="user_id" value="<?php echo $arr_user->user_id?>">
<table border="1" align="center">
    <tr><td colspan="2">&nbsp;</td></tr>
    <tr align="left">
        <td width="100px">User</td>
        <td width="200px"><input type="text" name="username" value="<?php echo $arr_user->username?>"></td>
    </tr>
    <tr align="left">
        <td width="100px">Password</td>
        <td width="200px"><input type="text" name="password" value="<?php echo $arr_user->password?>"></td>
    </tr>
    <tr align="left">
        <td width="100px">Type</td>
        <td width="200px"><select name="user_type"><?php echo get_option($arr_type$arr_user->user_type)?></select></td>
    </tr>
    <tr align="right"><td colspan="2"><input type="submit" value="Save"></td></tr>
</table>
</form>