<?php require_once 'libcollection.php'; startSession(); if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (isset($_POST['id'])) { $id = $_POST['id']; /***read book****/ if (isset($_POST['read'])) { db_connect(); $result = retrive_book('generatedbooks', $id, '*'); db_close(); $location = 'storygen.php?title=' . urlencode($result['title']) . '&story=' . urlencode($result['story']) . "&hero=" . urlencode($result['hero']) . '&villain=' . urlencode($result['villain']) . '&lair=' . urlencode($result['lair']) . '&page=0'; header('location: ' . $location); /***edit book***/ } elseif (isset($_POST['edit'])) { $_SESSION['edit'] = $id; header('location: selection.php'); /***delete book***/ } elseif (isset($_POST['delete'])) { delete_book($id); header('location: home.php'); } } } ?>
echo <<<_END <html> <head> <title>Selection</title> <style> @import url('css/style2.css'); </style> </head> <body> _END; if ($book_to_edit == '') { echo '<form method="post" action="generateNewStory.php">'; } else { echo '<form method="post" action="editStory.php">'; db_connect(); $book = retrive_book('generatedbooks', intval($book_to_edit), '*'); db_close(); $title = $book['title']; $story = $book['story']; $hero = $book['hero']; $villain = $book['villain']; } echo <<<_END <fieldset> <h1>Title:</h1> <input type="text" name="title" value="{$title}" /> <br/> <br/> <br/> <h1>Hero:</h1><br/>