PHP Classes

File: add.php

Recommend this page to a friend!
  Classes of Martin Latter   Noter   add.php   Download  
File: add.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Noter
Create and manage notes shared between users
Author: By
Last change: Update of add.php
Date: 1 year ago
Size: 1,610 bytes
 

Contents

Class file image Download
<?php

declare(strict_types=1);

#########################################
require('classes/helpers.class.php');
require(
'classes/sqlite.class.php');
require(
'classes/sqlitefunc.class.php');
#########################################

Helpers::validateUser();

require(
'includes/head.php');

?>

        <h1><a href="index.php">Add</a></h1>

        <div id="faddcont">

            <form action="<?php echo Helpers::selfSafe(); ?>" method="post">

                <div>
                    <label for="title">title</label>
                    <input type="text" name="title" id="title" maxlength="<?php echo CONFIG_MAX_TITLE_LEN; ?>">
                </div>

                <div id="tacont">
                    <label for="body">note</label>
                    <textarea id="body" name="body" cols="80" rows="2" maxlength="<?php echo CONFIG_MAX_BODY_LEN; ?>"></textarea>
                </div>

                <input type="hidden" name="add_flag">
                <input type="submit" value="add" class="clear">

            </form>

        </div>

<?php

if (isset($_POST['add_flag']))
{
   
$oNote = new SQLiteFunc();

    if ( ! empty(
$_POST['title']) && ! empty($_POST['body']))
    {
       
$aResults = $oNote->add($_POST['title'], $_POST['body']);

        if (
$aResults[0])
        {
            echo
'<p id="complete" class="success">' . $aResults[1] . '</p>';
        }
        else
        {
            echo
'<p class="error">' . $aResults[1] . '</p>';
        }
    }
    else
    {
        echo
'<p class="error">Incomplete or blank note entry.</p>';
    }

}

require(
'includes/foot.php');