Preview: addform.php
Size: 7.62 KB
/home/jambtst2015/public_html/giraffeng.com/admin/addform.php
<?php include("includes/head.php"); ?>
<?php include("includes/header.php"); ?>
<?php
/*---For Add---*/
if(empty($_POST['submit'])){ $_POST['submit']=''; }
if($_POST['submit'] == 'Save'){
include("image_file.php");
if($_FILES['filename']['type']=='application/pdf' || $_FILES['filename']['type']=='application/msword' || $_FILES['filename']['type']=='application/docx' || $_FILES['filename']['type'] == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document')
{
$src_subscription_form=$_FILES['filename']['tmp_name'];
$dest_subscription_form=time().$_FILES['filename']['name'];
$dest_subscription_form1="upload_file/".$dest_subscription_form;
//exit;
copy($src_subscription_form,$dest_subscription_form1);
}
/*----check username----*/
$chksql = "select `id` from `form_master` where `title`='".$_POST['title']."'";
$chkqry = mysql_query($chksql);
$getRow = mysql_num_rows($chkqry);
/*----end username check-*/
if($getRow > 0){
$error = 'This Title already exists.';
}
else{
if($_POST['title'] == ''){
$error = 'Please enter Title.';
}
else{
$insSql = "insert into `form_master` set ";
$insSql .= "title='".mysql_real_escape_string($_POST['title'])."', ";
$insSql .= "filename='".mysql_real_escape_string($dest_subscription_form)."', ";
$insSql .= "status='".$_POST['status']."', ";
$insSql .= "post_date=now() ";
//echo $insSql;exit;
mysql_query($insSql);
//include("mailuser.php");
header('location:forms.php?success=1');
exit();
}
}
}
else{
$_POST['title']='';
}
/*---End Add---*/
?>
<script type="text/javascript">
function Checkfiles()
{
var fup = document.getElementById('filename');
var fileName = fup.value;
var ext = fileName.substring(fileName.lastIndexOf('.') + 1);
if(ext == "pdf" || ext == "doc" || ext == "docx" || ext =="")
{
return true;
}
else
{
alert("Invalid File Type");
$('#filename').val('');
fup.focus();
return false;
}
}
</script>
<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" enctype="multipart/form-data">
<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 valign="top">
<div class="tbl-out">
<p class="client_table">
<i class="fa fa-edit"></i> Add Form
</p>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="center-tbl new-tbl">
<tr>
<td align="right" valign="top">*Title</td>
<td><input name="title" type="title" class="validate[required] textfield require_field" value="<?php echo $_POST['title']; ?>"/></td>
</tr>
<tr>
<td width="39%" align="right" valign="top">*Upload Form</td>
<td width="61%"><input name="filename" id="filename" type="file" class="validate[required] textfield require_field" /></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>
</select></td>
</tr>
</table>
</div>
</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 colspan="5" align="center">
<input name="submit" type="submit" value="Save" class="require float-none org" style=" margin-bottom:10px;" onclick="return Checkfiles();" />
<input type="button" name="back" id="back" class="require float-none" value="Cancel" style=" margin-bottom:10px;" onclick="window.history.back();" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<div class="clear"></div>
</div>
<?php include("includes/footer.php"); ?>
Directory Contents
Dirs: 17 × Files: 180