All pastes #514820 Raw Edit

Stuff

public text v1 · immutable
#514820 ·published 2007-05-27 22:34 UTC
rendered paste body
<?php
session_start();
// Coded by Starholdest/Elliott Gervais Copyright © 2006-2007
require("../sources/connect.php");
require("../sources/login.php");
?>
<html>
	<head>
		<title>Add books - Admin CP</title><link rel="stylesheet" type="text/css" href="../sources/style.css">
	</head>
		<div id="bigbox">
		<div id="maintext">
</html>
<?php
if ($_POST) {
	$_POST	= array_map('mysql_real_escape_string', $_POST);
	$error	= array();
	$query = mysql_fetch_array(mysql_query("SELECT * FROM `books` WHERE `title`='".$_POST['title']."' AND `author`='".$_POST['author']."'")) or die(mysql_error());
  
  if ($query >= 1) $error[]="That book already exists!";
	if($_POST['title']==null || $_POST['author']==null || $_POST['bookid']==null) $error[]="Please fill in the whole form";
	if(!is_numeric($_POST['bookid'])) $error[]="Book ID needs to be a number";
	
	if (count($error)==0) {
		echo "You successfully added a book";
	}
}

if (isset($error) && count($error)!=0 && isset($_POST)) {
	foreach ($error as $x) {
		echo $x."<br />";
	}
}

print_r($error);
?>

<html>
		<h1>Add books</h1>
		<form method="POST" action="">
		Title: <input type="text" name="title" size="50" maxlength="100"><br/>
		Author: <input type="text" name="author" size="50" maxlength="100"><br/>
		Book ID: <input type="text" name="bookid" size="5" maxlength="32"><br/><br/>
		<input type="submit" value="Add book"></form>
		<br/><br/><a href="./adminmain.php">Back to the Admin Control Panel</a><br/><a href="./adminbooks.php">View booklist / delete books</a>
	</div></div>
</html>