Example #1
0
<?php

require 'class-collection.php';
require 'form_tools.php';
$collection = new Collection('data.txt');
$errors = array();
$valid = "";
$file_error = "";
if (isset($_POST['title'])) {
    // make sure all data exists
    $valid = $collection->validate($_POST, $errors);
    if ($valid) {
        $book = $collection->format_data($_POST);
        $book = $collection->write_to_file($book);
        if ($book) {
            header("location:home.php?new=1");
        } else {
            $file_error = "File could not be opened.";
        }
    }
}
?>
<!DOCtype html>
<html lang="EN">
<head>
	<title>New Book</title>
	<link rel="stylesheet" type="text/css" href="style.css" media="all" />
</head>
	<body>
		<h1>New Book</h1>
		<?php