Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/mm/ada/icdp/
Upload File :
Current File : /var/www/html/mmishra/mm/ada/icdp/webusers.php

Please furnish these information in order to host user's profile on this website. User must be assigned a specific role.

<?php
checklogin($user);
$tbl = 'webusers';

$roles = array('user','admin','guest');

$rowid = $_REQUEST['rowid'];
$userid = $_REQUEST['userid'];
$passwd = $_POST['passwd'];
$fullname = $_POST['fullname'];
$email = $_POST['email'];
$contact = htmlsafe($_POST['contact']);
$profile = htmlsafe($_POST['profile']);
$roll = $_POST['role'];
$status = $_POST['status'];
$submit = $_POST['submit'];

$statuss = array('online','offline');

switch ($submit) {
case "SAVE":
        if (mysql_num_rows(mysql_query("select * from $tbl where webid='$webid' and userid='$userid'"))) {
                if ($passwd) mysql_query("update $tbl set passwd=password('$passwd') where userid='$userid'");
                mysql_query("update $tbl set fullname='$fullname',contact='$contact',email='$email',role='$roll',profile='$profile',status='$status'
                where webid='$webid' and userid='$userid'");
        } else {
                mysql_query("insert into $tbl(webid,userid,passwd,fullname,contact,email,role,profile,status,datecreation)
		values('$webid','$userid',password('$passwd'),'$fullname','$contact','$email','$roll','$profile','online',now())");
        }
	break;
case 'DELETE':
	mysql_query("delete from $tbl where webid='$webid' and userid='$userid'");
	break;
} 

$tbl = 'webusers';
if ($role == 'admin') {
        echo "<center><table cellpadding='5'>
	<tr bgcolor='silver'><td>Select User<br>
	<select name='userid' style='width: 150px' onchange=\"document.location.href='$PHP_SELF?conf=$conf&userid='+this.value\">
        <option value=''>New</option>";
        $rs = mysql_query("select * from $tbl where webid='$webid' order by userid");
        while ($o = mysql_fetch_object($rs)) {
                echo "<option value='$o->userid'";
                if ($userid == $o->userid) echo " selected";
                echo ">$o->userid</option>";
        }
        echo "</select></td>
	<td>Select Role<br>
	<select name='role' style='width: 150px'>";
        foreach ($roles as $rl){
                echo "<option value='$rl'";
                if ($rl == $roll) echo " selected";
                echo ">$rl</option>";
        }
        echo "</select></td>
	<td>Status<br>
	<select name='status' style='width: 150px'>";
	foreach ($statuss as $st) {
        	echo "<option value='$st'";
        	if ($status == $st) echo ' selected';
        	echo ">$st</option>";
	}
	echo "</select></td>
	</tr></table></center>";

	$rs = mysql_query("select * from $tbl where webid='$webid' and userid='$userid'");
} else if ($role == 'user') {
	$rs = mysql_query("select * from $tbl where webid='$webid' and userid='$user'");
}
if ($rs) {	
	$o = mysql_fetch_object($rs);
	$rowid = $o->rowid;
	$passwd = $o->passwd;
	$fullname = $o->fullname;
	$email = $o->email;
	$contact = htmlunsafe($o->contact);
	$profile = htmlunsafe($o->profile);
}
echo "
<center>
<table>
<tr><td>User ID *<br>
<input type='text' name='userid' value='$userid' size='60'";
if ($userid) echo ' readonly';
echo "></td></tr>
<tr><td>Password *<br>
<input type='password' name='passwd' value='' size='60'>
</td></tr>
<tr><td>Fullname *<br>
<input type='text' name='fullname' value='$fullname' size='60'>
</td></tr>
<tr><td>Email *<br>
<input type='text' name='email' value='$email' size='60'>
</td></tr>
<tr valign='top'><td>Contact Details<br>
<textarea name='contact' rows='3' cols='50'>$contact</textarea>
</td></tr>
<tr valign='top'><td>Brief Profile<br>
<textarea name='profile' rows='10' cols='50'>$profile</textarea>
</td></tr>
<tr><th><input type='submit' name='submit' value='SAVE' style='width: 80px'> ";
if ($userid) {
	echo "<input type='submit' name='submit' value='DELETE' style='width: 80px'>&nbsp;";
}
echo "</th></tr>
</table>
</center>";

?>