<?php
require_once "../Connect.php"; /*MySQL configuration and connect*/
if(IsSet($_POST['install'])) {
$query1 = "DROP TABLE IF EXISTS `Administrators`;
CREATE TABLE `Administrators` (
`AdminID` int(11) NOT NULL AUTO_INCREMENT ,
`FirstName` varchar (50) NOT NULL,
`LastName` varchar (50) NOT NULL,
`Username` varchar (50) NOT NULL,
`Password` varchar (50) NOT NULL,
PRIMARY KEY (`AdminID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
$result1 = mysql_query($query1) or die (mysql_error());
$query2 = "DROP TABLE IF EXISTS `Posts`;
CREATE TABLE `Posts` (
`PostID` int(11) NOT NULL AUTO_INCREMENT,
`Title` varchar (100) NOT NULL,
`Intro` text NOT NULL,
`Body` text NOT NULL,
`Date` varchar (100) NOT NULL,
`Writer` int (11) NOT NULL,
`PictureID` int (11) NOT NULL,
PRIMARY KEY (`PostID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
$result2 = mysql_query($query2) or die(mysql_error());
$query3 = "DROP TABLE IF EXISTS `Pictures`;
CREATE TABLE `Pictures` (
`PictureID` int(11) NOT NULL AUTO_INCREMENT,
`Picture` varchar (100) NOT NULL,
`Path` varchar (500) NOT NULL,
`Height` varchar (100) NOT NULL,
`Widht` varchar (100) NOT NULL,
PRIMARY KEY (`PictureID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
$result3 = mysql_query($query3) or die(mysql_error());
$query4 = "DROP TABLE IF EXISTS `Videos`;
CREATE TABLE `Videos` (
`VideoID` int(11) NOT NULL AUTO_INCREMENT,
`Video` varchar (100) NOT NULL,
`Path` varchar (500) NOT NULL,
`Lenght` varchar (100) NOT NULL,
PRIMARY KEY (`VideoID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
$result4 = mysql_query($query4) or die(mysql_error());
$query5 = "DROP TABLE IF EXISTS `Guests`;
CREATE TABLE `Guests` (
`GuestID` int(11) NOT NULL AUTO_INCREMENT,
`Name` varchar (100) NOT NULL,
`Age` varchar (100) NOT NULL,
`Bloglink` varchar (100) NOT NULL,
`Password` varchar (100) NOT NULL,
PRIMARY KEY (`GuestID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
$result5 = mysql_query($query5) or die(mysql_error());
$query6 = "DROP TABLE IF EXISTS `Comments`;
CREATE TABLE `Comments` (
`CommentID` int(11) NOT NULL AUTO_INCREMENT,
`GuestID` int(11) NOT NULL,
`Title` varchar (100) NOT NULL,
`Comment` text NOT NULL,
`Date` varchar (100) NOT NULL,
`Bloglink` varchar (100) NOT NULL,
PRIMARY KEY (`CommentID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;";
$result6 = mysql_query($query6) or die(mysql_error());
}
if ( empty($result1)) {
echo "<b>An error ocurred with query 1! Please try again!<br>";
}
if ( empty($result2)) {
echo "<b>An error ocurred with query 2! Please try again!<br>";
}
if ( empty($result3)) {
echo "<b>An error ocurred with query 3! Please try again!<br>";
}
if ( empty($result4)) {
echo "<b>An error ocurred with query 4! Please try again!<br>";
}
if ( empty($result5)) {
echo "<b>An error ocurred with query 5! Please try again!<br>";
}
if ( empty($result6)) {
echo "<b>An error ocurred with query 6! Please try again!<br>";
} else {
echo "<h1>PostON is installed on your webserver!!!</h1><br><a href='../admin/Index.php'>Go to the admin Login!</a>";
}
?>