My custom built books manager
Posted: Wed Jul 30, 2008 1:59 pm
NOTE: I custom built this app for MY own use and not to be distributed to others - the source code reflects this:
As many of the processor scripts in my app look the same, i am just posting one script - the book adding script - up here for criticism and checking.
form_processor.php
Thanks for any (constructive) criticism and reviewing!
As many of the processor scripts in my app look the same, i am just posting one script - the book adding script - up here for criticism and checking.
form_processor.php
Code: Select all
<?php
include 'config.php';
$id = $_POST['id'];
$location = $_POST['location'];
$title = $_POST['title'];
$author = $_POST['author'];
$subject = $_POST['subject'];
$isbn = $_POST['isbn'];
//open database connection
$connection = mysql_connect($host, $user, $pass) or die ('Unable to connect!');
//select database
mysql_select_db($database) or die ('Unable to select database!');
//generate and execute query
$query = "INSERT INTO `library`.`books` (`ID`, `Location`, `Title`, `Author`, `Subject`, `ISBN`) VALUES ('$id', '$location', '$title', '$author', '$subject', '$isbn')";
$result = mysql_query($query) or die ('Error in query: ' . $query);
//print result
echo 'New record added succesfully!';
echo '<br>';
echo "<a href='test1.php'>Return >></a>";
//close database connection
mysql_close($connection);
?>