PHP Classes

File: fwphp/glomodul/blog_akram/AddNewPost.php

Recommend this page to a friend!
  Classes of Slavko Srakocic   B12 PHP FW   fwphp/glomodul/blog_akram/AddNewPost.php   Download  
File: fwphp/glomodul/blog_akram/AddNewPost.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: 3,186 bytes
 

Contents

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

Confirm_Login();


if(isset(
$_POST["Submit"]))
{
                              
//echo '<pre><b>$_POST</b>='; print_r($_POST); echo '</pre>';
 
unset($_POST["Submit"]) ;

  
$Title=escp($_POST["Title"]);
  
$Category=escp($_POST["Category"]);
  
$Post=escp($_POST["Post"]);
  
$Date_Time = date('Y-m-d H:i:s', time());
                   
//date_default_timezone_set();
                    //$CurrentTime=time();
                    //"%Y-%m-%d %H:%M:%S"
                    //$Date_Time=strftime("%B-%d-%Y %H:%M:%S",$CurrentTime);
 
$Admin=$_SESSION["Username"];
 
$Im_age=$_FILES["imag"]["name"];
 
$Target="Upload/".basename($_FILES["imag"]["name"]);



  if(empty(
$Title)){
   
$_SESSION["ErrorMessage"]="Title can't be empty";
   
Redirect_to("AddNewPost.php");
  }elseif(
strlen($Title)<2){
   
$_SESSION["ErrorMessage"]="Title Should be at-least 2 Characters";
   
Redirect_to("AddNewPost.php");



  }else{
   
$Query=get_cursor("INSERT INTO admin_panel(datetim,title,category,author,imag,post)
    VALUES('
$Date_Time','$Title','$Category','$Admin','$Im_age','$Post')", 'cc');

   
move_uploaded_file($_FILES["imag"]["tmp_name"],$Target);

    if(
$Query){
   
$_SESSION['SuccessMessage']="Post Added Successfully";
   
//Redirect_to("AddNewPost.php");
   
}else{
   
$_SESSION["ErrorMessage"]="Something Went Wrong. Try Again !";
   
//Redirect_to("AddNewPost.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 Post</h1>
  <?php echo Message();
        echo
SuccessMessage();
 
?>
<div>
<form action="AddNewPost.php" method="post" enctype="multipart/form-data">
  <fieldset>
  <div class="form-group">
  <label for="title"><span class="FieldInfo">Title:</span></label>
  <input class="form-control" type="text" name="Title" id="title" placeholder="Title">
  </div>
  <div class="form-group">
  <label for="categoryselect"><span class="FieldInfo">Category:</span></label>
  <select class="form-control" id="categoryselect" name="Category" >
  <?php
global $ConnectingDB;
$ViewQuery=get_cursor("SELECT * FROM category ORDER BY id desc");
while(
$rowt=$ViewQuery->fetch(PDO::FETCH_ASSOC)){
 
 
$rowt = rlows($rowt) ;
 
 
$Id=$rowt["id"];
 
$CategoryName=$rowt["name"];
?>
  <option><?php echo $CategoryName; ?></option>
  <?php } ?>

  </select>
  </div>
  <div class="form-group">
  <label for="imagselect"><span class="FieldInfo">Select imag:</span></label>
  <input type="File" class="form-control" name="imag" id="imagselect">
  </div>
  <div class="form-group">
  <label for="postarea"><span class="FieldInfo">Post:</span></label>
  <textarea class="form-control" name="Post" id="postarea"></textarea>
  <br>
<input class="btn btn-success btn-block" type="Submit" name="Submit" value="Add New Post">
  </fieldset>
  <br>
</form>
</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");