Esempio n. 1
0
include_once 'resources\\init.php';
if (isset($_POST['title'], $_POST['contents'], $_POST['category'])) {
    $errors = array();
    $title = trim($_POST['title']);
    $contents = trim($_POST['contents']);
    if (empty($title)) {
        $errors[] = "You need to supply a title.";
    } else {
        if (strlen($title) > 255) {
            $errors[] = "The title cannot be longer than 255 characters.";
        }
    }
    if (empty($contents)) {
        $errors[] = "You need to supply some text.";
    }
    if (!category_exits('id', $_POST['category'])) {
        $errors[] = "The category does not exit.";
    }
    if (empty($errors)) {
        add_post($title, $contents, $_POST['category']);
        $id = mysql_insert_id();
        Header("Location: index.php?id={$id}");
        die;
    }
}
?>

<html>
        <head>
           <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1">
Esempio n. 2
0
<?php

include_once 'resources\\init.php';
if (isset($_POST['name'])) {
    $name = trim($_POST['name']);
    if (empty($name)) {
        $error = "You must submit a category name.";
    } else {
        if (category_exits("name", $name)) {
            $error = "Thats category already exits.";
        } else {
            if (strlen($name) > 24) {
                $error = "Category names can only be upto 24 characters.";
            } else {
                if (!ctype_alpha($name)) {
                    $error = "Category names should be characters only.";
                }
            }
        }
    }
    if (!isset($error)) {
        add_category($name);
        Header("Location: add_post.php");
        die;
    }
}
?>
<html>
	<head>
	    <meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1">