Hi everyone,
I just have a couple of questions on making an install scblockedript which basically creates a database for a website.
Basically I want to make a file (install.php) which will create the database and return if everything is okay.
I've coded what I thought it would be like. But apparently its not right.
This is what I've got so far (ps, Dont comment on my sloppy coding.)
<?php
echo "
<html>
<body>
<form action='install.php' method='post' >
<center>
<h1>Would you like to install the current website?</h1>
<br />
<br />
<table>
<tr>
<td>
<input type='submit' name='yes' value='Yes!' />
</td>
<td>
<input type='submit' name='no' value='No' />
</td>
</tr>
</table>
</form>
</body>
</html>
";
if(isset($_POST['no'])){
echo "<scblockedript type='text/javascblockedript'> location.href='index.php'</scblockedript>";
}elseif(isset($_POST['yes'])){
$user = 'upload_user';
$pass = '';
$dbConnect = mysql_connect('localhost',$user,$pass);
if($dbConnect){
echo "sorry could not connect to local host using :" . $user . " as the username" or die(mysql_error());
}else{
$sqlQuery = "
CREATE DATABASE `upload_users`;
CREATE TABLE IF NOT EXISTS `comments` (
`page` text NOT NULL,
`comment` text NOT NULL,
`new` text NOT NULL,
`user` text NOT NULL,
`ID` int(11) NOT NULL auto_increment,
`to` text NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
";
if(mysql_query($sqlQuery)){
echo "successful query - Creating Database `upload_users` and table `comments` <br />" or die(mysql_error());
}
$sqlQuery = "INSERT INTO `comments` (`page`, `comment`, `new`, `user`, `ID`, `to`) VALUES
('get=1&user=admin', ':)', '1', 'admin', 1, 'admin')";
if(mysql_query($sqlQuery)){
echo "successful query - Inserting data into `comments` table <br />" or die(mysql_error());
}
$sqlQuery = "CREATE TABLE IF NOT EXISTS `friends` (
`friend` text NOT NULL,
`friend2` text NOT NULL,
`a1` text NOT NULL,
`a2` text NOT NULL,
`ID` int(11) NOT NULL auto_increment,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1" ;
if(mysql_query($sqlQuery)){
echo "successful query - Creating table `friends` <br />" or die(mysql_error());
}
$sqlQuery = "CREATE TABLE IF NOT EXISTS `images` (
`path` text NOT NULL,
`album` text NOT NULL,
`owner` text NOT NULL,
`ID` int(11) NOT NULL auto_increment,
`des` text NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;";
if(mysql_query($sqlQuery)){
echo "successful query - Creating table `images` <br />" or die(mysql_error());
}
$sqlQuery = "INSERT INTO `images` (`path`, `album`, `owner`, `ID`, `des`) VALUES
('quantum-solace-olga.jpg', '1', 'admin', 1, '');";
if(mysql_query($sqlQuery)){
echo "successful query - Inserting data into `images` table <br />" or die(mysql_error());
}
$sqlQuery = "CREATE TABLE IF NOT EXISTS `PM` (
`to` text NOT NULL,
`from` text NOT NULL,
`date` text NOT NULL,
`ID` int(11) NOT NULL auto_increment,
`subject` text NOT NULL,
`new` text NOT NULL,
`mess` text NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;";
if(mysql_query($sqlQuery)){
echo "successful query - created table `PM` <br />" or die(mysql_error());
}
$sqlQuery = "INSERT INTO `PM` (`to`, `from`, `date`, `ID`, `subject`, `new`, `mess`) VALUES
('admin', 'admin new page!', 'Thu, 16 Jul 09 12:00:47 +0100', 1, 'Test', '1', 'lol')";
if(mysql_query($sqlQuery)){
echo "Successful query - Inserted data into table `PM` <br />" or die(mysql_error());
}
$sqlQuery = "CREATE TABLE IF NOT EXISTS `profile` (
`user` text NOT NULL,
`main` text NOT NULL,
`links` text NOT NULL,
`h` text NOT NULL,
`ID` int(11) NOT NULL auto_increment,
`avatar` text NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;";
if(mysql_query($sqlQuery)){
echo "Successful query - Created table `profile`" or die(mysql_error());
}
$sqlQuery = "INSERT INTO `profile` (`user`, `main`, `links`, `h`, `ID`, `avatar`) VALUES
('admin', 'First Account!', 'allow', 'admin new page!', 1, 'http://uploadimage.co.uk/upload/uploads/admin/quantum-solace-olga.jpg');";
if(mysql_query($sqlQuery)){
echo "Successful query - Inserted data into `profile` table" or die(mysql_error());
}
$sqlQuery = "CREATE TABLE IF NOT EXISTS `users` (
`uname` text NOT NULL,
`upassword` text NOT NULL,
`avatar` text NOT NULL,
`email` text NOT NULL,
`ID` int(11) NOT NULL auto_increment,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;";
if(mysql_query($sqlQuery)){
echo "successful query - Created table `users`" or die(mysql_error());
}
$sqlQuery = "INSERT INTO `users` (`uname`, `upassword`, `avatar`, `email`, `ID`) VALUES
('admin', '32a8216baa0bbcfbe47d35cbeb734643', '', 'youremail', 1);";
if(mysql_query($sqlQuery)){
echo "successful query - Inserted data into `users` table" or die(mysql_error());
}
}
}
?>

THE PEOPLE UNITED WILL NEVER BE DEFEATED!
don't care for money, and money's not for me,
the money fueled this empire and our racist history.
Although I'm forced to use it, the rules have all been set.
But life is not worth living when yer soul is in debt!
MONEY KILLS.
MONEY RAPES.
MONEY LIES.
MONEY HATES. |