Preview: userform_edit.php
Size: 19.04 KB
/home/jambtst2015/public_html/giraffeng.com/admin/userform_edit.php
<?php include("includes/head.php"); ?>
<?php include("includes/header.php"); ?>
<script type="text/javascript">
function openfietld() {
$('#passfield').slideDown("slow");
$('#cancel').slideDown("slow");
document.getElementById("password").focus();
$('#changepassword').slideUp();
}
function cancelfietld() {
$('#passfield').slideUp("slow");
$('#cancel').slideUp("slow");
//document.getElementById("password").focus();
$('#changepassword').slideDown("slow");
}
</script>
<?php
//chk userclass
/* if($level!=1){
if($_SESSION['sat_login_id']!=$_REQUEST['userid']){
echo '<script>window.location.href = "index.php?error=1";</script>';
}
} */
/*---For Add---*/
$updater_class = mysql_fetch_array(mysql_query("select `userclass` from `sat_users` where `user_id`='".$_SESSION['sat_login_id']."'"));
if(empty($_POST['submit'])){ $_POST['submit']=''; }
if($_POST['submit'] == 'Save'){
if($_REQUEST['password1']!=''){
$password = md5($_REQUEST['password1']);
}else{
$password = $_REQUEST['password'];
}
$error = '';
/*----check username----*/
$chksql = "select `user_id` from `sat_users` where `username`='".$_POST['username']."' and `user_id`!='".$_POST['userId']."'";
$chkqry = mysql_query($chksql);
$getRow = mysql_num_rows($chkqry);
/*----end username check-*/
/*----check email----*/
$chksql_email = "select `user_id` from `sat_users` where `email`='".$_POST['email']."' and `user_id`!='".$_POST['userId']."'";
$chkqry_email = mysql_query($chksql_email);
$getRowemail = mysql_num_rows($chkqry_email);
/*----end username check-*/
if($getRow > 0){
$error = 'This User ID already exists.';
}
if($getRowemail > 0){
$error = 'This email address already exists.';
}
else{
if($_POST['email'] == ''){
$error = 'Please enter email address.';
}
else if(!isEmail($_POST['email'])){
$error = 'Invalid email address. Please enter valid email address.';
}
else if($_REQUEST['security_question']!='' && $_REQUEST['security_answer']==''){
$error = "Answer field must not be empty";
}
else{
$phone = $_POST['phone1']."-".$_POST['phone2']."-".$_POST['phone3'];
$upSql = "update `sat_users` set ";
$upSql .= "firstname='".mysql_real_escape_string($_POST['firstname'])."', ";
$upSql .= "lastname='".mysql_real_escape_string($_POST['lastname'])."', ";
//$upSql .= "username='".mysql_real_escape_string($_POST['username'])."', ";
$upSql .= "edit_date=now(), ";
//$upSql .= "user_initial='".$_POST['user_initial']."', ";
if($_POST['userclass']!=''){
$upSql .= "userclass='".$_POST['userclass']."', ";
}
$upSql .= "password='".$password."', ";
$upSql .= "security_question='".mysql_real_escape_string($_POST['security_question'])."', ";
$upSql .= "security_answer='".mysql_real_escape_string($_POST['security_answer'])."', ";
if($_POST['status']!=''){
$upSql .= "status='".$_POST['status']."', ";
}
$upSql .= "email='".$_POST['email']."', ";
$upSql .= "phone='".$phone."', ";
$upSql .= "extension_phone='".$_POST['extension_phone']."'";
//$upSql .= "password='".$password."'";
$upSql .= " where user_id='".$_POST['userId']."'";
//echo $upSql;
//exit;
mysql_query($upSql);
/*----make history------*/
/*$insSql = "insert into `sat_users_history` set ";
$insSql .= "user_id='".mysql_real_escape_string($_POST['userId'])."', ";
$insSql .= "name='".mysql_real_escape_string($_POST['name'])."', ";
$insSql .= "username='".mysql_real_escape_string($_POST['username_hide'])."', ";
$insSql .= "effective_date='".mysql_real_escape_string($_POST['effective_date_hide'])."', ";
$insSql .= "title='".$_POST['title_hide']."', ";
$insSql .= "user_level='".$_POST['user_level_hide']."', ";
$insSql .= "password='".$_POST['password_hide']."', ";
$insSql .= "password_recover='".$_POST['password_recover_hide']."', ";
$insSql .= "securityq1='".mysql_real_escape_string($_POST['securityq1_hide'])."', ";
$insSql .= "securitya1='".mysql_real_escape_string($_POST['securitya1_hide'])."', ";
$insSql .= "securityq2='".mysql_real_escape_string($_POST['securityq2_hide'])."', ";
$insSql .= "securitya2='".mysql_real_escape_string($_POST['securitya2_hide'])."', ";
$insSql .= "securityq3='".mysql_real_escape_string($_POST['securityq3_hide'])."', ";
$insSql .= "securitya3='".mysql_real_escape_string($_POST['securitya3_hide'])."', ";
$insSql .= "status='".$_POST['status_hide']."', ";
$insSql .= "email='".$_POST['email_hide']."', ";
$insSql .= "reports_to_name='".$_POST['reports_to_name_hide']."', ";
$insSql .= "notes='".$_POST['notes_hide']."', ";
$insSql .= "notes_desc='".mysql_real_escape_string($_POST['notes_desc_hide'])."', ";
$insSql .= "rcv_reqs_email='".$_POST['rcv_reqs_email_hide']."', ";
$insSql .= "submittals_emails='".$_POST['submittals_emails_hide']."', ";
$insSql .= "rvc_hotlist_email='".$_POST['rvc_hotlist_email_hide']."', ";
$insSql .= "inactive_date='".$_POST['inactive_date_hide']."', ";
$insSql .= "phone='".$_POST['phone_hide']."', ";
$insSql .= "extension_phone='".$_POST['extension_phone_hide']."'";
//echo $insSql;
mysql_query($insSql);*/
/*----end----*/
if($_POST['rec']!=''){
//exit(11111111111);
header("location:index.php?success=2");
exit();
}else{
header("location:view_user.php?success=2&userid=".$_POST['userId']."&page=".$_REQUEST['page']."&name=".$_REQUEST['src_name']."&email=".$_REQUEST['src_email']."&username=".$_REQUEST['src_username']."&title=".$_REQUEST['src_title']."&status=".$_REQUEST['src_status']."&rcv_reqs_email=".$_REQUEST['src_rcv_reqs_email']."&submittals_emails=".$_REQUEST['src_submittals_emails']."&rvc_hotlist_email=".$_REQUEST['src_rvc_hotlist_email']."&order=".$_REQUEST['src_order']."&submit2=".$_REQUEST['src_submit2']);
exit();
}
}
}
}
/*---fetch value----*/
echo $userId = $_REQUEST['id'];
$result=mysql_fetch_array(mysql_query("select * from user where id='".$userId."'"));print_r($result);
/*---End Add---*/
?>
<script>
jQuery.noConflict();
(function($) {jQuery(document).ready(function(){
// binds form submission and fields to the validation engine
jQuery("#formID").validationEngine();
});})(jQuery);
</script>
<script type="text/javascript">
function setLevel(val){
document.getElementById('user_level_show').value = val;
document.getElementById('user_level').value = val;
}
function open_notes()
{
if(document.getElementById('notes').checked==true)
{
document.getElementById('notes_div').style.display='block';
}
if(document.getElementById('notes1').checked==true)
{
document.getElementById('notes_desc').value='';
document.getElementById('notes_div').style.display='none';
}
}
</script>
<script type="text/javascript">
function getkey(e)
{
if (window.event)
return window.event.keyCode;
else if (e)
return e.which;
else
return null;
}
function goodchars(e, goods)
{
var key, keychar;
key = getkey(e);
if (key == null) return true;
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();
goods = goods.toLowerCase();
if (goods.indexOf(keychar) != -1)
return true;
if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
return true;
return false;
}
function setLevel(val){
document.getElementById('user_level_show').value = val;
document.getElementById('user_level').value = val;
}
function ChangeFocuszip(cur,nex)
{
var value=document.getElementById(cur).value;
if(value.length==5)
{
document.getElementById(nex).focus();
}
}
function ChangeFocus1(cur,nex)
{
var value=document.getElementById(cur).value;
if(value.length==3)
{
document.getElementById(nex).focus();
}
}
function ChangeFocus(cur,nex)
{
var value=document.getElementById(cur).value;
if(value.length==3)
{
document.getElementById(nex).focus();
}
}
function ChangeFocus1(cur,nex)
{
var value=document.getElementById(cur).value;
if(value.length==2)
{
document.getElementById(nex).focus();
}
}
</script>
<div class="container_bottom_section tbl_cls_new">
<form name="myfrm" action="" method="post" id="formID"> <input type="hidden" value="<?php echo $userId; ?>" name="userId" /> <input type="hidden" value="<?php echo $_REQUEST['rec']; ?>" name="rec" /> <input name="password_hide" type="hidden" class="textfield" value="<?php echo $result['password']; ?>" /> <input name="password_recover_hide" type="hidden" class="textfield" value="<?php echo $result['password_recover']; ?>" /> <input name="effective_date_hide" type="hidden" class="textfield" value="<?php echo $result['effective_date']; ?>" /> <input name="status_hide" type="hidden" class="textfield" value="<?php echo $result['status']; ?>" /> <input name="notes_hide" type="hidden" class="textfield" value="<?php echo $result['notes']; ?>" /> <input name="rcv_reqs_email_hide" type="hidden" class="textfield" value="<?php echo $result['rcv_reqs_email']; ?>" /> <input name="submittals_emails_hide" type="hidden" class="textfield" value="<?php echo $result['submittals_emails']; ?>" /> <input name="rvc_hotlist_email_hide" type="hidden" class="textfield" value="<?php echo $result['rvc_hotlist_email']; ?>" /> <input type="hidden" value="<?php echo $_REQUEST['page']; ?>" name="page" /> <input type="hidden" value="<?php echo $_REQUEST['name']; ?>" name="src_name" /> <input type="hidden" value="<?php echo $_REQUEST['email']; ?>" name="src_email" /> <input type="hidden" value="<?php echo $_REQUEST['username']; ?>" name="src_username" /> <input type="hidden" value="<?php echo $_REQUEST['order']; ?>" name="src_order" /> <input type="hidden" value="<?php echo $_REQUEST['title']; ?>" name="src_title" /> <input type="hidden" value="<?php echo $_REQUEST['rcv_reqs_email']; ?>" name="src_rcv_reqs_email" /> <input type="hidden" value="<?php echo $_REQUEST['submittals_emails']; ?>" name="src_submittals_emails" /> <input type="hidden" value="<?php echo $_REQUEST['rvc_hotlist_email']; ?>" name="src_rvc_hotlist_email" /> <input type="hidden" value="<?php echo $_REQUEST['submit2']; ?>" name="src_submit2" /> <input type="hidden" value="<?php echo $_REQUEST['status']; ?>" name="src_status" />
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<?php if(empty($error)){$error='';}
if($error!=''){
?>
<tr>
<td colspan="5">
<div class="error"><?php echo $error; ?></div>
</td>
</tr>
<?php } ?>
<tr>
<td width="89%" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0" style="border: 1px solid #cccccc;"> <tr> <td colspan="2" style="padding: 0 !important;"> <p class="client_table"> <i class="fa fa-edit"></i> Edit User </p> </td> <!-- <tr id="mailchk" style="display:none;"> <td align="right" valign="top"> </td> <td><div id="mail_view" style="padding:5px 0 7px 3px;"></div></td> </tr> --> </tr> <tr> <td> <input name="password" type="hidden" value="<?php echo $result['password']; ?>" /> <table width="100%" border="0" cellspacing="0" cellpadding="0" class="center-tbl new-tbl"> <tr> <td align="right" valign="top">User ID</td> <td><input name="username" id="username" type="text" class="validate[required] textfield require_field" value="<?php echo $result['id']; ?>" readonly="readonly" /></td> </tr> <?php if($result['userclass']=='3' && $updater_class['userclass'] == '1'){ ?> <tr> <td align="right" valign="top">Password</td> <td> <div class="chng-pass"> ******</div> <div id="changepassword" class="b545" style="margin-bottom:5px;"> <a href="javascript:void(0);" onclick="return openfietld();" style="text-decoration:none" class="require float-none sm">Change Password</a> </div> <div id="passfield" class="txf954" style="margin-bottom:5px; display:none;"> <input type="password" name="password1" id="password" class="validate[required,minSize[6],maxSize[20]] textfield require_field" maxlength="8"> <div> <a href="javascript:void(0);" onclick="return cancelfietld();" style="text-decoration:none;margin: 0 !important;" id="cancel" class="require float-none sm no-margin">Cancel</a> </div> <div style="clear:both;"></div> </div> </td> </tr> <?php } ?> <tr> <td width="39%" align="right" valign="top">*Name</td> <td width="61%"><input name="firstname" type="text" class="validate[required] textfield require_field" value="<?php echo $result['name']; ?>" /></td> </tr> <!-- <tr> <td width="39%" align="right" valign="top">*Last Name</td> <td width="61%"><input name="lastname" type="text" class="validate[required] textfield require_field" value="<?php //echo $result['lastname']; ?>" /></td> </tr>--> <tr> <td align="right" valign="top">*Email Address</td> <td><input name="email" type="text" class="validate[required,custom[email]] textfield require_field" value="<?php echo $result['email_id']; ?>" <?php if($updater_class['userclass']!='1'){ ?>readonly="readonly"<?php } ?> /></td> </tr> <tr> <td align="right" valign="top">Phone</td> <td><?php /*?><input name="phone" type="text" class="textfield" value="<?php echo $result['phone']; ?>" /><?php */?> <?php $phone = $result['phone']; $array_phone = explode('-', $phone); ?> <input name="phone1" id="work_phone1" type="text" maxlength="3" value="<?php echo $array_phone[0]; ?>" onkeypress="return goodchars(event,'1234567890');" onkeyup="javascript:ChangeFocus('work_phone1','work_phone2');" class="textfield" style="width:26px; border:#7F9DB9 1px solid !important; " /> - <input name="phone2" type="text" maxlength="3" id="work_phone2" value="<?php echo $array_phone[1]; ?>" onkeypress="return goodchars(event,'1234567890');" onkeyup="javascript:ChangeFocus('work_phone2','work_phone3');" style="width:26px; border:#7F9DB9 1px solid !important; " class="textfield" /> - <input name="phone3" type="text" maxlength="4" id="work_phone3" value="<?php echo $array_phone[2]; ?>" onkeypress="return goodchars(event,'1234567890');" style="width:33px; border:#7F9DB9 1px solid !important; " class="textfield" /> ( <input type="text" value="<?php echo $result['extension_phone']; ?>" name="extension_phone" onkeypress="return goodchars(event,'1234567890');" style="width:38px; border:#7F9DB9 1px solid !important; " class="textfield" maxlength="5" /> ) </td> </tr> <!-- <tr> <td align="right" valign="top">*User Class</td> <td><select name="userclass" class="validate[required] selectfield require_select" <?php //if($level!=1){ ?> disabled="disabled"<?php // } ?>> <option value="">--Select User Class --</option> <option value="1" <?php //if($result['userclass']=='1') { ?>selected="selected"<?php //} ?>>Admin</option> <option value="2" <?php //if($result['userclass']=='2') { ?>selected="selected"<?php //} ?>>Manager</option> <option value="3" <?php //if($result['userclass']=='3') { ?>selected="selected"<?php //} ?>>User</option> </select></td> </tr>--> <!--<tr> <td align="right" valign="top">*User Initial</td> <td> <input name="user_initial" id="user_initial" type="text" class="validate[required] textfield require_field" readonly="readonly" value="<?php// echo $result['user_initial']; ?>" /> </td> </tr>--> <!--<tr> <td width="212" align="right" valign="top">Security Question</td> <td width="222"> <select id="security_question" name="security_question" class="selectfield require_select"> <option value="">-- Select Question --</option> <option value="Best Actor/ Actress" <?php //if($result['security_question']=='Best Actor/ Actress') { ?>selected="selected"<?php //} ?>>Best Actor/ Actress</option> <option value="City of Birth" <?php //if($result['security_question']=='City of Birth') { ?>selected="selected"<?php //} ?>>City of Birth</option> <option value="First Car" <?php //if($result['security_question']=='First Car') { ?>selected="selected"<?php //} ?>>First Car</option> <option value="First School Name" <?php //if($result['security_question']=='First School Name') { ?>selected="selected"<?php //} ?>>First School Name</option> <option value="Mother Maiden Name" <?php //if($result['security_question']=='Mother Maiden Name') { ?>selected="selected"<?php //} ?>>Mother Maiden Name</option> <option value="Not Logged In" <?php //if($result['security_question']=='Not Logged In') { ?>selected="selected"<?php //} ?>>Not Logged In</option> </select> </td> </tr>--> <!--<tr> <td width="212" align="right" valign="top">Security Answer</td> <td width="222"> <input type="text" id="security_answer" name="security_answer" class="textfield require_field" value="<?php //echo $result['security_answer']; ?>"> </td> </tr>--> <!--<tr> <td align="right" valign="top">Status</td> <td><select name="status" class="selectfield require_select" <?php //if($level!=1){ ?> disabled="disabled"<?php //} ?>> <option value="Active" <?php //if($result['status']=='Active') { ?>selected="selected"<?php //} ?>>Active</option> <option value="Inactive" <?php //if($result['status']=='Inactive') { ?>selected="selected"<?php //} ?>>Inactive</option> <option value="Hold" <?php //if($result['status']=='Hold') { ?>selected="selected"<?php //} ?>>Hold</option> </select></td> </tr>--> <tr> <td width="212" align="right" valign="top">Add Date</td> <td width="222"> <input type="text" name="added_date" class="validate[required] textfield require_field" disabled="disabled" value="<?php echo change_dateformat_reverse($result['add_date']); ?>" readonly="readonly" /> </td> </tr> <tr> <td> </td> <td align=""> <input name="submit" type="submit" value="Save" class="require org float-none" style=" margin-bottom:10px;margin-left: 0 !important;" /> <input name="cancel" type="button" value="Cancel" class="require float-none" style=" margin-bottom:10px;" onclick="window.history.back();" /> </td> </tr> </table> </td> </tr>
</table> </td> </tr></table>
</form>
<div class="clear"></div>
</div>
<?php include("includes/footer.php"); ?>
Directory Contents
Dirs: 17 × Files: 180