<?php
include("sess_page.php");
include("include/protect.php");
include("include/dbconnect.php");
extract($_POST);
$uname=$_SESSION['uname'];
if(isset($btnSubmit))
{
	if(trim($category)=="")
	{
	$msg="Enter the Category";
	}
	else
	{
$max_qry = mysql_query("select max(id) maxid from category");
	$max_row = mysql_fetch_array($max_qry);
	$id=$max_row['maxid']+1;
	$rdate=date("Y-m-d");
	$pass=md5($pwd);
		$uqry="insert into category(id,category) values($id,'$category')";
		$res=mysql_query($uqry);
		if($res)
		{
		$msg="Added Successfully...";
		}
		else
		{
		$msg="Could not be stored!";
		}
	}

}
//////////
if($_REQUEST['act']=="del")
{
$did=$_REQUEST['did'];
mysql_query("delete from category where id=$did");
header("location:add_cat.php");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php include("include/title.php"); ?></title>
<link href="style.css" rel="stylesheet" type="text/css">
<script language="javascript" src="include/menu.js"></script>
<script language="javascript">
function del()
{
	if(!confirm("Are you sure want to delete?"))
	{
	return false;
	}
	return true;
}
</script>
  <link rel="stylesheet" href="../css/bootstrap.min.css">
    <!-- Site CSS -->
    <link rel="stylesheet" href="../css/style.css">
    <!-- Responsive CSS -->
    <link rel="stylesheet" href="../css/responsive.css">
    <!-- Custom CSS -->
    <link rel="stylesheet" href="../css/custom.css">
</head>

<body><form id="form1" name="form1" method="post" action="">
 <header class="main-header">
        <!-- Start Navigation -->
        <nav class="navbar navbar-expand-lg navbar-light bg-light navbar-default bootsnav">
            <div class="container">
                <!-- Start Header Navigation -->
                <div class="navbar-header">
                    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar-menu" aria-controls="navbars-rs-food" aria-expanded="false" aria-label="Toggle navigation">
                    <i class="fa fa-bars"></i>
                </button>
                    <a class="navbar-brand" href="index.html"><img src="../images/logo.png" class="logo" alt=""></a>
                </div>
                <!-- End Header Navigation -->

                <!-- Collect the nav links, forms, and other content for toggling -->
                <div class="collapse navbar-collapse" id="navbar-menu">
                    <ul class="nav navbar-nav ml-auto" data-in="fadeInDown" data-out="fadeOutUp">
                        <li class="nav-item "><a class="nav-link" href="index.php">Home</a></li>
                        <li class="dropdown active">
                            <a href="#" class="nav-link " data-toggle="dropdown">PRODUCTS</a>
                            <ul class="dropdown-menu">
								<li><a href="add_cat.php">Add Category</a></li>
								<li><a href="add_products.php">Add Products</a></li>
                                <li><a href="view_products.php">View Products</a></li>
                              
                            </ul>
                        </li>
                        
                        <li class="dropdown">
						<a class="nav-link" href="admin.php" ata-toggle="dropdown">Info</a>
						<ul class="dropdown-menu">
								<li><a href="user_details.php">User Information</a></li>
								<li><a href="admin_view_purchase_user.php">View Products for user</a></li>
                                <li><a href="tot_Sell.php">Total sales</a></li>
                                <li><a href="admin_qut_status.php">Stock Quantity Status</a></li>
                            </ul>
						</li>
                        <li class="nav-item"><a class="nav-link" href="../index.html" >Logout</a></li>
                    </ul>
                </div>
                <!-- /.navbar-collapse -->

               
                <!-- End Atribute Navigation -->
            </div>
            <!-- Start Side Menu -->
            <div class="side">
                <a href="#" class="close-side"><i class="fa fa-times"></i></a>
                <li class="cart-box">
                    <ul class="cart-list">
                        <li>
                            <a href="#" class="photo"><img src="../images/bg2.jpg" class="cart-thumb" alt="" /></a>
                            <h6><a href="#">Delica omtantur </a></h6>
                            <p>1x - <span class="price">$80.00</span></p>
                        </li>
                        <li>
                            <a href="#" class="photo"><img src="../images/bg1.jpg" class="cart-thumb" alt="" /></a>
                            <h6><a href="#">Omnes ocurreret</a></h6>
                            <p>1x - <span class="price">$60.00</span></p>
                        </li>
                        <li>
                            <a href="#" class="photo"><img src="../images/bg1.jpg" class="cart-thumb" alt="" /></a>
                            <h6><a href="#">Agam facilisis</a></h6>
                            <p>1x - <span class="price">$40.00</span></p>
                        </li>
                        <li class="total">
                            <a href="#" class="btn btn-default hvr-hover btn-cart">VIEW CART</a>
                            <span class="float-right"><strong>Total</strong>: $180.00</span>
                        </li>
                    </ul>
                </li>
            </div>
            <!-- End Side Menu -->
        </nav>
        <!-- End Navigation -->
    </header>
    <!-- End Main Top -->

    <!-- Start Top Search -->
    <div class="top-search">
        <div class="container">
            <div class="input-group">
                <span class="input-group-addon"><i class="fa fa-search"></i></span>
                <input type="text" class="form-control" placeholder="Search">
                <span class="input-group-addon close-search"><i class="fa fa-times"></i></span>
            </div>
        </div>
    </div>
    <!-- End Top Search -->

    <!-- Start Slider -->
    <div id="slides-shop" class="cover-slides">
        <ul class="slides-container">
            <li class="text-center">
                <img src="../images/bg1.jpg" alt="">
                <div class="container">
                    <div class="row">
                        <div class="col-md-12">
                            <h1 class="m-b-20"><strong>Welcome To <br> Freshshop</strong></h1>
                            <p class="m-b-40">See how your users experience your website in realtime or view <br> trends to see any changes in performance over time.</p>
                           
                        </div>
                    </div>
                </div>
            </li>
            
            <li class="text-center">
                <img src="../images/bg3.jpg" alt="">
                <div class="container">
                    <div class="row">
                        <div class="col-md-12">
                            <h1 class="m-b-20"><strong>Welcome To <br> Freshshop</strong></h1>
                            <p class="m-b-40">See how your users experience your website in realtime or view <br> trends to see any changes in performance over time.</p>
                            
                        </div>
                    </div>
                </div>
            </li>
        </ul>
        
    </div>
    <!-- End Slider -->
  <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  
    <tr>
      <td align="center" valign="top"><p>&nbsp;</p>
        <p class="style1"><?php echo $msg; ?></p>
       
	   
         <div class="col-md-12">
                                    <div class="form-group">
                                       <input type="text" name="category" class="form-control" placeholder="Add Category" />
                                        <div class="help-block with-errors"></div>
                                    </div>
                                </div>
          <tr>
            <td colspan="2" align="center"><input type="submit" name="btnSubmit" value="Submit" class="btn hvr-hover" /></td>
          </tr>
        </table>
        <blockquote>
          <p>&nbsp;</p>
          <table width="268" border="0" cellspacing="0" cellpadding="5" class="table">
		   <thead class="thead-dark">
            <tr>
              <th scope="col">Sno</th>
              <th scope="col">Category</th>
              <th scope="col">Action</th>
            </tr>
			 </thead>
			<?php
			$i=0;
			$q2=mysql_query("select * from category");
			while($r2=mysql_fetch_array($q2))
			{ $i++;
			?>
            <tr>
              <td><?php echo $i; ?></td>
              <td><?php echo $r2['category']; ?></td>
              <td><a href="add_cat.php?act=del&did=<?php echo $r2['id']; ?>" onclick="return del()">Delete</a></td>
            </tr>
			<?php
			}
			?>
          </table>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
          <p>&nbsp;</p>
      </blockquote>
      <p>&nbsp;</p>        <h3>&nbsp;</h3></td>
    </tr>
    <tr>
      <td align="center" >&nbsp;</td>
    </tr>
  </table>
</form>
 <div class="footer-copyright">
        <p class="footer-company">&nbsp;</p>
    </div>
    <!-- End copyright  -->
<?php
if(isset($btn2))
{
//header("location:search_user.php?gettxt=".$gettxt."&utype=".$utype);
?>
<script language="javascript">
window.location.href="search_user.php?gettxt=<?php echo $gettxt; ?>&utype=<?php echo $utype; ?>";
</script>
<?php
}
?>
<script src="../js/jquery-3.2.1.min.js"></script>
    <script src="../js/popper.min.js"></script>
    <script src="../js/bootstrap.min.js"></script>
    <!-- ALL PLUGINS -->
    <script src="../js/jquery.superslides.min.js"></script>
    <script src="../js/bootstrap-select.js"></script>
    <script src="../js/inewsticker.js"></script>
    <script src="../js/bootsnav.js."></script>
    <script src="../js/images-loded.min.js"></script>
    <script src="../js/isotope.min.js"></script>
    <script src="../js/owl.carousel.min.js"></script>
    <script src="../js/baguetteBox.min.js"></script>
    <script src="../js/form-validator.min.js"></script>
    <script src="../js/contact-form-script.js"></script>
    <script src="../js/custom.js"></script>
</body>
</html>
