reenadak icon

Add record in easy login pro

reenadak | PRO | 10/29/17 09:22:37 AM UTC | 0 ⭐ | 337 👁️ | Never ⏰ | []
PHP |

2.6 KB

|

None

|

0 👍

/

0 👎

<?php require_once '../../app/init.php'; 
 
if(isset($_GET['logout'])) { Auth::logout(); redirect_to( App::url('admin.php') ); }
if(Auth::guest()) { echo View::make('admin.login')->render(); exit; }
if(!Auth::userCan('dashboard')) { echo View::make('admin.restricted')->render(); exit; }
 
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.
 
echo View::make('header')->render();
 
 
if ($_SERVER['REQUEST_METHOD'] === 'POST')
{
        // Gather inputs.
        $quote      = filter_var($_POST['quote'], FILTER_SANITIZE_STRING);
        $category   = filter_var($_POST['category'], FILTER_SANITIZE_STRING);
 
        // Validate inputs.
 
        if(strlen($quote)<1)
        {
            echo "Entered quote is invalid.";
        }
        elseif(strlen($category)<1)
        {
            echo "Entered category is invalid.";
        }
        else
        {
            DB::insert('insert into quotes (quote, category) values (?, ?)', array($quote, $category));
            $msg = "<h3>Quote added successfully.</h3>";
        }     
}
 
?>
 
<div class="row">
    <div class="col-md-8">
        <h3 class="page-header">Add Quote</h3>
 
        <?php if(isset($msg)) echo $msg; ?>
 
    <form method="post" action="">
        <div class="form-group">
            <div class="col-xs-12">
 
                <div class="input-group">
                    <div class="input-group-addon textarea-addon"><span class="glyphicon glyphicon-pencil"></span> &nbsp; Quote</div>
                    <textarea class="form-control" rows="6" name="quote" placeholder="Type quote here.." style="font-size: 1.5em;"></textarea>
                </div>
                
                <br>
 
                <div class="input-group" style="font-size: 1.5em;">
                <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span> &nbsp; Category</span>
                    <select class="form-control" name="category">
                    <?php
                        $categories = DB::select('SELECT DISTINCT category FROM quotes ORDER BY category');
 
                        foreach ($categories as $cat){
                            echo "<option value='".$cat->category."'>".$cat->category."</option>";
                        }
                    ?>
                    </select>
                </div>
 
                <br>
 
                <div class="input-group">
                    <button type="submit" name="formSubmit" class="btn btn-primary"><span class="glyphicon glyphicon-envelope"></span> Add Quote </button>
                </div>
            </div>
        </div>
    </form>
    <br>&nbsp;<br><p>
        
        <a href='quotes.php' class="btn btn-warning pull-right"><span class="glyphicon glyphicon-th-list"> </span> Quotes </a>
     
     <p>
 
    </div>
</div>
 
 
<?php echo View::make('footer')->render(); ?>

Comments