Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /***
- * make_db.php
- * automatically create a database for administrator login
- ***/
- $mysql_host="localhost";
- $mysql_user="root";
- $mysql_pass="blah";
- $database = "punkcms"; // database to make
- // connect
- $connection = mysql_connect($mysql_host, $mysql_user, $mysql_pass);
- // check the connection
- if (!$connection) {
- die('Could not connect: ' . mysql_error());
- }
- // if we cant select our database, we need to create it
- if (!mysql_select_db($database, $connection)) {
- if (!mysql_query("CREATE DATABASE " . $database, $connection)) {
- die('Error creating database: ' . mysql_error());
- }
- $table = "Administrator";
- // create the table
- mysql_select_db($database, $connection);
- mysql_query("CREATE TABLE " . $table .
- "(username varchar(15), password varchar(15))" , $connection
- );
- mysql_query("INSERT INTO " . $table .
- "(username, password) VALUES ('admin', 'thisismypassword')" , $connection
- );
- } else {
- echo "database exists!";
- }
- // close connection
- mysql_close($connection);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement