Вход Регистрация
Файл: Source/admin/add_page.php
Строк: 63
<?php
/*
 * Script name: Points4Prize
 * Author: Soft Projects
 * Date created: 15/07/2015
 */
 
include "common.php";
head();
?>
<script src="//cdn.ckeditor.com/4.4.7/full/ckeditor.js"></script>
<div class="body content rows scroll-y">
    <!-- Page header -->
    <div class="page-heading">
        <h1><b>Add page</b> </h1>
    </div>
    <!-- End page header -->
    <!-- Begin info box -->
    <div class="row">
        <div class="col-md-12">
            <div class="box-info">
                <h2>Add page</h2>
                <?php
                
if (isset($_POST['add'])) {
                    
$title htmlspecialchars($_POST['title']);
                    
$content htmlspecialchars($_POST['content']);

                    
$title sprintf("%s"mysql_real_escape_string($title));
                    
$content sprintf("%s"mysql_real_escape_string($content));

                    
$check mysql_query("SELECT title FROM pages WHERE title='{$title}'") or die(mysql_error());
                    
$result mysql_num_rows($check);

                    if (
$title == NULL) {
                        echo 
"<div class='alert alert-danger' role='alert'>Please add title of page.</div>";
                    } elseif (
$content == NULL) {
                        echo 
"<div class='alert alert-danger' role='alert'>Please add content.</div>";
                    } else if (
strlen($title) < or strlen($title) > 20) {
                        echo 
"<div class='alert alert-danger' role='alert'>The title should be from 3-20 characters.</div>";
                    } elseif (
preg_match("/[^a-zA-Z0-9_.-]/"$title)) {
                        echo 
"<div class='alert alert-danger' role='alert'>The title must not contain special characters.</div>";
                    } elseif (
$result >= 1) {
                        echo 
"<div class='alert alert-danger' role='alert'>Page already exists with that name</div>";
                    } else {
                        
$query "INSERT INTO `pages` (`content`, `title`) VALUES ('$content', '$title');";
                        
mysql_query($query);
                        echo 
'<div class="alert alert-success" role="alert">The page was successfully added.<br />';
                        echo 
'You can view page at: <b><a target="_blank" href="' $GLOBALS['site_url'] . 'show/' $title '">' $GLOBALS['site_url'] . 'show/' $title '</a></b></div>';
                    }
                }
                
?>
                <form action="" method="post">

                    <p>
                        <label>
                            Page title
                        </label>
                        <input name="title" class="form-control" type="text">
                    </p>

                    <p>
                        <label>
                            Content
                        </label>
                        <textarea name="content"  class="form-control" rows="3"></textarea>
                        <script>
                            CKEDITOR.replace('content');
                        </script>
                    </p>

                    <input type="submit"  class="btn btn-success" name="add" value="Add page" />
                </form>


            </div>
            <?php
            footer
();
            
?>
        </div>
    </div>
Онлайн: 0
Реклама