Join us at IRC!
Become the change you seek in the world. - Gandhi
Friday, May 25, 2012
Navigation
Members Online
Total Online: 25
Web Spiders: 13
Guests Online: 23
Members Online: 2

Registered Members: 70208
Newest Member: andresuran
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

PHP/MySQL install script

DarkMantis
Member



Posts: 192
Location: Bringing Security To You!
Joined: 23.04.06
Rank:
Elite
Posted on 01-10-09 10:12
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.
Author

RE: PHP/MySQL install script

ynori7
Future Emperor of Earth



Posts: 1481
Location: #valhalla
Joined: 08.10.07
Rank:
Diabolical
Posted on 01-10-09 14:00
DarkMantis wrote:
I've coded what I thought it would be like. But apparently its not right.

That's really long, man. Don't expect people to trace all through that. Where does it die? If you don't know, start putting in echos in various places so you can see where it dies.




ynori7 http://halls-of-valhalla.org
Author

RE: PHP/MySQL install script

DarkMantis
Member



Posts: 192
Location: Bringing Security To You!
Joined: 23.04.06
Rank:
Elite
Posted on 01-10-09 14:27
Yeah no worries, I just wanted to see if anyone could instantly see if I'm being stupid on this one, but it doesn't matter any more, I've sorted it out now, Thanks again.




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.
Author

RE: PHP/MySQL install script

f16e7
Banned

Posts: 89
Location:
Joined: 21.09.09
Rank:
Apprentice
Warn Level: 100
Posted on 01-10-09 14:46
Next time you post code, please also post error messages you got, and what -you- think the problem could and/or couldn't be.

Also, if you fixed something, edit your first post to say so and also HOW you fixed it.

Good job on fixing it, btw.
Guest
Username

Password

Remember Me


Bookmark This Page
Affiliates
Adverts

 

 

Links
By using, viewing or obtaining any information contained on this site, you agree to the disclaimer.

© HellBound Hackers 2008- 2009. Since 3rd December 2004.