/* this script will handle the variables passed from the insert_transaction.html file */
/* declare some relevant variables */
PRINT "";
PRINT "
Insert New Transaction";
PRINT "";
$dbname = "example";
$cid = $_POST["cid"];
$pid = $_POST["pid"];
$tdate = $_POST["tdate"];
$tqnt = $_POST["tqnt"];
/* MySQL table created to store the data */
$tablename = "transaction";
/* make connection to database */
MYSQL_CONNECT() OR DIE("Unable to connect to database server");
@mysql_select_db("$dbname") or die("Unable to select database");
$today = date("Y-m-d");
PRINT "Today is: $today.
";
PRINT "You identified yourself as $username.";
PRINT "
";
PRINT "You issued the following INSERT query:
";
PRINT "";
PRINT "- Customer id: $cid";
PRINT "
- Product id: $pid";
PRINT "
- Transaction date: $tdate";
PRINT "
- Transaction quantity: $tqnt";
PRINT "
";
PRINT "
";
/* Insert information into table */
$query = "INSERT INTO $tablename VALUES('$cid','$pid', '$tdate', '$tqnt')";
$result = MYSQL_QUERY($query);
PRINT "Database server response:
";
if($result != 0){
$affected_rows = mysql_affected_rows();
PRINT "Query OK. Rows affected $affected_rows";
}else{
PRINT "Query FAILED. Probably you don't have the proper access rights!";
}
PRINT "
";
PRINT "Back";
PRINT "";
PRINT "";
/* Close the database connection */
MYSQL_CLOSE();
?>