Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/iws8/html/ilight/
Upload File :
Current File : /var/www/html/mmishra/iws8/html/ilight/webusers.inc

<h3 align='left'>Web Users</h3>
<center>
<?php

$tbl = 'webusers';
$userid = $_POST["userid"];

if ($_POST["submit"] == 'SAVE' && $userid) {
	
	$role = $_POST["role"];
	$email = $_POST["email"];
	
	if (mysql_num_rows(mysql_query("select * from $tbl where userid='$userid'"))) {
		mysql_query("update $tbl set role='$role',email='$email' 
		where userid='$userid'");
	} else {
		mysql_query("insert into $tbl(userid,role,email,datecreation) 
		values('$userid','$role','$email',now())");
	}

} else if ($_POST["submit"] == 'DELETE') {
	mysql_query("delete from $tbl where userid='$userid'");

}

$rs = mysql_query("select userid,role,email,datecreation from $tbl order by role");
if ($rs) {
        $colHeads = mysql_num_fields($rs);

        echo "<table border='1' width='60%'>\n<tr><th>Sr</th>";

        for ($i=0; $i < $colHeads; $i++) { // Header
                $fld = ucwords(str_replace("_"," ",mysql_field_name($rs, $i)));
                echo "<th>$fld</th>";
        }

        echo "</tr>\n";

        while ($row = mysql_fetch_row($rs)) { //data
		$j++;
                echo "<tr><td>$j</td><td>".implode($row,"</td><td>")."</td></tr>\n";
        }

        echo "</table>\n";
} else {
        echo "Sorry";
}

?>

<table>
<tr><th colspan='2'>Add/Edit</th></tr>
<tr><td>User ID</td>
<td><input type='text' name='userid' value='<?php echo $userid; ?>' size='35'></td>
<td><input type='submit' name='submit' value='FIND'></td></tr>

<?php

if ($_POST["submit"] == 'FIND') {

	$rs = mysql_query("select * from $tbl where userid='$userid'");
	while ($o = mysql_fetch_object($rs)) {
		$role = $o->role;
		$email = $o->email;
	}
}

echo "<tr><td>Role</td>
<td><select name='role'>";

foreach ($roles as $rl) {
	echo "<option value='$rl'";
	if ($role == $rl) echo ' selected';
	echo ">$rl</option>";
}

echo "</td></tr>
<tr><td>Email</td>
<td><input type='text' name='email' value='$email' size='35'></td></tr>";

?>

<tr><th colspan='2'>
<input type='submit' name='submit' value='SAVE'>
<input type='submit' name='submit' value='DELETE'>
</th></tr>
</table>
</center>