PHP Classes

File: fwphp/glomodul/blog_akram/Categories.php

Recommend this page to a friend!
  Classes of Slavko Srakocic   B12 PHP FW   fwphp/glomodul/blog_akram/Categories.php   Download  
File: fwphp/glomodul/blog_akram/Categories.php
Role: Example script
Content type: text/plain
Description: Example script
Class: B12 PHP FW
Manage database records with a PDO CRUD interface
Author: By
Last change: ver 11.0.2.0 mnu, adrs, msg, mkd. Same module db adapter for any shared db adapter
ver 11.0.1.0 mnu, adrs, msg, mkd. Same module db adapter for any shared db adapter
Date: 1 year ago
Size: 2,570 bytes
 

Contents

Class file image Download
<?php
$title
='Add Categorie' ;
require_once(
"ahdr.php");

Confirm_Login();


if(isset(
$_POST["Submit"])){

$Category=escp($_POST["Category"]);


  
$Date_Time = date('Y-m-d H:i:s', time());
$Admin=$_SESSION["Username"];


if(empty(
$Category)){
 
$_SESSION["ErrorMessage"]="All Fields must be filled out";
 
Redirect_to("Categories.php");
 
}elseif(
strlen($Category)>99){
 
$_SESSION["ErrorMessage"]="Too long Name for Category";
 
Redirect_to("Categories.php");
 
 
 
 
}else{
 
$Query=get_cursor("INSERT INTO category(datetim,name,creatorname)
  VALUES('
$Date_Time','$Category','$Admin')", 'cc');
  if(
$Query){
   
$_SESSION['SuccessMessage']="Category Added Successfully";
   
Redirect_to("Categories.php");
  }else{
   
$_SESSION["ErrorMessage"]="Category failed to Add";
   
Redirect_to("Categories.php");
  }
 
}
 
}

?>


<div class="container-fluid">
<div class="row">
 


<?php
$active
= strtolower(basename(__FILE__ , '.php')) ;
require_once(
"aside_admin.php");
?>



  <div class="col-sm-10">
  <h1>Add new Categorie</h1>
  <?php echo Message();
        echo
SuccessMessage();
 
?>
<div>
<form action="Categories.php" method="post">
  <fieldset>
  <div class="form-group">
  <label for="categoryname"><span class="FieldInfo">Name:</span></label>
  <input class="form-control" type="text" name="Category" id="categoryname" placeholder="Name">
  </div>
  <br>
<input class="btn btn-success btn-block" type="Submit" name="Submit" value="Add New Category">
  </fieldset>
  <br>
</form>
</div>
<div class="table-responsive">
  <table class="table table-striped table-hover">
  <tr>
    <th>Sr No.</th>
    <th>Date & Time</th>
    <th>Category Name</th>
    <th>Creator Name</th>
    <th>Action</th>
   
  </tr>
<?php
global $ConnectingDB;
$ViewQuery=get_cursor("SELECT * FROM category ORDER BY id desc");
$SrNo=0;
while(
$rowt=$ViewQuery->fetch(PDO::FETCH_ASSOC)){

 
$rowt = rlows($rowt) ;

 
$Id=$rowt["id"];
 
$Date_Time=$rowt["datetim"];
 
$CategoryName=$rowt["name"];
 
$CreatorName=$rowt["creatorname"];
 
$SrNo++;


 
 


?>
<tr>
  <td><?php echo $SrNo; ?></td>
  <td><?php echo $Date_Time; ?></td>
  <td><?php echo $CategoryName; ?></td>
  <td><?php echo $CreatorName; ?></td>
  <td><a href="DeleteCategory.php?id=<?php echo $Id;?>">
  <span class="btn btn-danger">Delete</span>
  </a></td>
 
</tr>
   
  <?php } ?>
  </table>
</div>
  </div> <!-- Ending of Main Area-->
 
</div> <!-- Ending of Row-->
 
</div> <!-- Ending of Container-->

<div style="height: 10px; background: #27AAE1;"></div>

     
<?php
require_once("aftr.php");