Preview: userform_7-2-15.php
Size: 13.59 KB
/home/jambtst2015/public_html/giraffeng.com/admin/userform_7-2-15.php
<?php include("includes/head.php"); ?>
<?php include("includes/header.php"); ?>
<?php
/*---For Add---*/
if(empty($_POST['submit'])){ $_POST['submit']=''; }
if($_POST['submit'] == 'Save'){
if($_REQUEST['security_question']!='' && $_REQUEST['security_answer']==''){
$error = "Answer field must not be empty";
}else{
/*----check username----*/
$chksql = "select `user_id` from `sat_users` where `username`='".$_POST['username']."'";
$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']."'";
$chkqry_email = mysql_query($chksql_email);
$getRowemail = mysql_num_rows($chkqry_email);
/*----end username check-*/
/*----check email----*/
$chksql_initial = "select `user_id` from `sat_users` where `user_initial`='".$_POST['user_initial']."'";
$chkqry_initial = mysql_query($chksql_initial);
$getRowinitial = mysql_num_rows($chkqry_initial);
/*----end username check-*/
if($getRow > 0){
$error = 'This User ID already exists.';
}
elseif($getRowemail > 0){
$error = 'This email address already exists.';
}
elseif($getRowinitial > 0){
$error = 'This user initial already exists.';
}
else{
if($_POST['username'] == ''){
$error = 'Please enter user id.';
}
elseif($_POST['password'] == ''){
$error = 'Please enter password.';
}
elseif($_POST['email'] == ''){
$error = 'Please enter email address.';
}
else if(!isEmail($_POST['email'])){
$error = 'Invalid email address. Please enter valid email address.';
}
else{
$phone = $_POST['phone1']."-".$_POST['phone2']."-".$_POST['phone3'];
$insSql = "insert into `sat_users` set ";
$insSql .= "firstname='".mysql_real_escape_string($_POST['firstname'])."', ";
$insSql .= "lastname='".mysql_real_escape_string($_POST['lastname'])."', ";
$insSql .= "username='".mysql_real_escape_string($_POST['username'])."', ";
$insSql .= "add_date=now(), ";
$insSql .= "user_initial='".strtoupper($_POST['user_initial'])."', ";
$insSql .= "userclass='".$_POST['userclass']."', ";
$insSql .= "password='".md5($_POST['password'])."', ";
$insSql .= "security_question='".mysql_real_escape_string($_POST['security_question'])."', ";
$insSql .= "security_answer='".mysql_real_escape_string($_POST['security_answer'])."', ";
$insSql .= "status='".$_POST['status']."', ";
$insSql .= "email='".$_POST['email']."', ";
$insSql .= "phone='".$phone."', ";
$insSql .= "extension_phone='".$_POST['extension_phone']."'";
//echo $insSql;
mysql_query($insSql);
//include("mailuser.php");
header('location:user.php?success=1');
exit();
}
}
}
}
else{
$_POST['name']='';
$_POST['username']='';
$_POST['effective_date']='';
$_POST['title']='';
$_POST['user_level_show']='';
$_POST['user_level']='';
$_POST['password']='';
$_POST['securityq1']='';
$_POST['securitya1']='';
$_POST['securityq2']='';
$_POST['securitya2']='';
$_POST['securityq3']='';
$_POST['securitya3']='';
$_POST['status']='';
$_POST['email']='';
$_POST['reports_to_name']='';
$_POST['notes']='';
$_POST['rcv_reqs_email']='';
$_POST['submittals_emails']='';
$_POST['rvc_hotlist_email']='';
$_POST['inactive_date']='';
$_POST['phone']='';
}
/*---End Add---*/
?>
<script>
function formSub(){
//alert(11111111);
document.formID.submit();
return true;
}
jQuery.noConflict();
(function($) {jQuery(document).ready(function(){
// binds form submission and fields to the validation engine
jQuery("#formID").validationEngine('attach', {
onValidationComplete: function(form, status){
//alert("The form status is: " +status+", it will never submit");
if(status == true){
//$('input[type="submit"]').attr('disabled','disabled');
return formSub();
}
}
});
});})(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>
<script type="text/javascript">
$(function(){
$('#username').keyup(function() {
//alert('Handler for .keyup() called.');
var val = $('#username').val();
$.ajax({
url : 'check.php',
type : 'POST',
data : 'val=' + val + '&type=username',
//dataType : 'json',
beforeSend : function(jqXHR, settings ){
//alert(1);
},
success : function( data, textStatus, jqXHR){
//alert(data);
$('#mailchk').show("slow");
$('#mail_view').html(data);
},
//complete : function( jqXHR, textStatus){
//alert(3);
//},
error : function( jqXHR, textStatus, errorThrown){
}
});
});
});
</script>
<div class="container_bottom_section tbl_cls_new">
<form name="formID" action="" method="post" id="formID">
<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="29%" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<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 $_POST['username']; ?>" /></td>
</tr>
<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>
<td align="right" valign="top">*Password</td>
<td><input name="password" type="password" class="validate[required,minSize[6],maxSize[20]] textfield require_field" /></td>
</tr>
<tr>
<td width="39%" align="right" valign="top">*First Name</td>
<td width="61%"><input name="firstname" type="text" class="validate[required] textfield require_field" value="<?php echo $_POST['firstname']; ?>" /></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 $_POST['lastname']; ?>" /></td>
</tr>
</table>
</td>
<td width="6%" valign="top"> </td>
<td width="29%" valign="top"><table width="96%" border="0" cellspacing="0" cellpadding="0">
<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 $_POST['email']; ?>" /></td>
</tr>
<tr>
<td align="right" valign="top">Phone</td>
<td><?php /*?><input name="phone" type="text" class="textfield" value="<?php echo $_POST['phone']; ?>" /><?php */?>
<input name="phone1" id="work_phone1" type="text" maxlength="3" value="<?php echo $_POST['phone1']; ?>" onkeypress="return goodchars(event,'1234567890');" onkeyup="javascript:ChangeFocus('work_phone1','work_phone2');" class="textfield" style="width:30px; border:#7F9DB9 1px solid !important; " />
-
<input name="phone2" type="text" maxlength="3" id="work_phone2" value="<?php echo $_POST['phone2']; ?>" onkeypress="return goodchars(event,'1234567890');" onkeyup="javascript:ChangeFocus('work_phone2','work_phone3');" style="width:30px; border:#7F9DB9 1px solid !important; " class="textfield" />
-
<input name="phone3" type="text" maxlength="4" id="work_phone3" value="<?php echo $_POST['phone3']; ?>" onkeypress="return goodchars(event,'1234567890');" style="width:35px; border:#7F9DB9 1px solid !important; " class="textfield" />
(
<input type="text" value="<?php echo $_POST['extension_phone']; ?>" name="extension_phone" onkeypress="return goodchars(event,'1234567890');" style="width:35px; 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">
<option value="">--Select User Class --</option>
<option value="1" <?php if($_POST['userclass']=='1') { ?>selected="selected"<?php } ?>>Admin</option>
<option value="2" <?php if($_POST['userclass']=='2') { ?>selected="selected"<?php } ?>>Manager</option>
<option value="3" <?php if($_POST['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" value="<?php echo $_POST['user_initial']; ?>" />
</td>
</tr>
</table>
</td>
<td width="2%" valign="top"> </td>
<td width="34%" valign="top"><table width="96%" border="0" cellspacing="0" cellpadding="0">
<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($_POST['security_question']=='Best Actor/ Actress') { ?>selected="selected"<?php } ?>>Best Actor/ Actress</option>
<option value="City of Birth" <?php if($_POST['security_question']=='City of Birth') { ?>selected="selected"<?php } ?>>City of Birth</option>
<option value="First Car" <?php if($_POST['security_question']=='First Car') { ?>selected="selected"<?php } ?>>First Car</option>
<option value="First School Name" <?php if($_POST['security_question']=='First School Name') { ?>selected="selected"<?php } ?>>First School Name</option>
<option value="Mother Maiden Name" <?php if($_POST['security_question']=='Mother Maiden Name') { ?>selected="selected"<?php } ?>>Mother Maiden Name</option>
<option value="Not Logged In" <?php if($_POST['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 $_POST['security_answer']; ?>">
</td>
</tr>
<tr>
<td align="right" valign="top">Status</td>
<td><select name="status" class="selectfield require_select">
<option value="Active" <?php if($_POST['status']=='Active') { ?>selected="selected"<?php } ?>>Active</option>
<option value="Inactive" <?php if($_POST['status']=='Inactive') { ?>selected="selected"<?php } ?>>Inactive</option>
<option value="Hold" <?php if($_POST['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" value="<?php echo date('m/d/Y'); ?>" readonly="readonly" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="5" align="center">
<input name="submit" type="submit" value="Save" class="submit" style=" margin-bottom:10px;" />
<input type="button" name="back" id="back" class="submit" value="Cancel" style=" margin-bottom:10px;" onclick="window.history.back();" />
</td>
</tr>
</table>
</form>
<div class="clear"></div>
</div>
<?php include("includes/footer.php"); ?>
Directory Contents
Dirs: 17 × Files: 180