reenadak

Add record in easy login pro

Oct 29th, 2017
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.60 KB | None | 0 0
  1. <?php require_once '../../app/init.php';
  2.  
  3. if(isset($_GET['logout'])) { Auth::logout(); redirect_to( App::url('admin.php') ); }
  4. if(Auth::guest()) { echo View::make('admin.login')->render(); exit; }
  5. if(!Auth::userCan('dashboard')) { echo View::make('admin.restricted')->render(); exit; }
  6.  
  7. if(Auth::user()->role_id !=1 ) { die("You must be logged in as <i>mukeshdak</i> to access this content."); } // You must be an admin.
  8.  
  9. echo View::make('header')->render();
  10.  
  11.  
  12. if ($_SERVER['REQUEST_METHOD'] === 'POST')
  13. {
  14.         // Gather inputs.
  15.         $quote      = filter_var($_POST['quote'], FILTER_SANITIZE_STRING);
  16.         $category   = filter_var($_POST['category'], FILTER_SANITIZE_STRING);
  17.  
  18.         // Validate inputs.
  19.  
  20.         if(strlen($quote)<1)
  21.         {
  22.             echo "Entered quote is invalid.";
  23.         }
  24.         elseif(strlen($category)<1)
  25.         {
  26.             echo "Entered category is invalid.";
  27.         }
  28.         else
  29.         {
  30.             DB::insert('insert into quotes (quote, category) values (?, ?)', array($quote, $category));
  31.             $msg = "<h3>Quote added successfully.</h3>";
  32.         }    
  33. }
  34.  
  35. ?>
  36.  
  37. <div class="row">
  38.     <div class="col-md-8">
  39.         <h3 class="page-header">Add Quote</h3>
  40.  
  41.         <?php if(isset($msg)) echo $msg; ?>
  42.  
  43.     <form method="post" action="">
  44.         <div class="form-group">
  45.             <div class="col-xs-12">
  46.  
  47.                 <div class="input-group">
  48.                     <div class="input-group-addon textarea-addon"><span class="glyphicon glyphicon-pencil"></span> &nbsp; Quote</div>
  49.                     <textarea class="form-control" rows="6" name="quote" placeholder="Type quote here.." style="font-size: 1.5em;"></textarea>
  50.                 </div>
  51.                
  52.                 <br>
  53.  
  54.                 <div class="input-group" style="font-size: 1.5em;">
  55.                 <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span> &nbsp; Category</span>
  56.                     <select class="form-control" name="category">
  57.                     <?php
  58.                         $categories = DB::select('SELECT DISTINCT category FROM quotes ORDER BY category');
  59.  
  60.                         foreach ($categories as $cat){
  61.                             echo "<option value='".$cat->category."'>".$cat->category."</option>";
  62.                         }
  63.                     ?>
  64.                     </select>
  65.                 </div>
  66.  
  67.                 <br>
  68.  
  69.                 <div class="input-group">
  70.                     <button type="submit" name="formSubmit" class="btn btn-primary"><span class="glyphicon glyphicon-envelope"></span> Add Quote </button>
  71.                 </div>
  72.             </div>
  73.         </div>
  74.     </form>
  75.     <br>&nbsp;<br><p>
  76.        
  77.         <a href='quotes.php' class="btn btn-warning pull-right"><span class="glyphicon glyphicon-th-list"> </span> Quotes </a>
  78.      
  79.      <p>
  80.  
  81.     </div>
  82. </div>
  83.  
  84.  
  85. <?php echo View::make('footer')->render(); ?>
Advertisement
Add Comment
Please, Sign In to add comment