Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php session_start() ?>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>Login page</title>
- </head>
- <body>
- <center><h3>Enter your credentials</h3></center>
- <form name="Form1" method="post" action="index.php">
- Username: <input type="text" name="username" />
- Password: <input type="text" name="password" />
- DB Name: <input type="text" name="dbname" />
- <input type="submit" name="submit" />
- </form>
- <?php
- if (!empty($_POST['username']) && !empty($_POST['password']) && !empty($_POST['dbname']))
- {
- $_SESSION['dbname'] = $_POST['dbname'];
- $_SESSION['username'] = $_POST['username'];
- $_SESSION['password'] = $_POST['password'];
- $dsn = 'mysql:host=localhost';
- $user = 'root';
- $password = 'ONGOINGwarfare1+2+3+';
- try {
- $dbh = new PDO($dsn, $user, $password);
- } catch (PDOException $e) {
- echo 'Connection failed : ' , $e->getMessage();
- }
- $SQL1 = "CREATE DATABASE {$_SESSION['dbname']}";
- $dbh->query($SQL1);
- $SQL2 = "CREATE USER {$_SESSION['username']} IDENTIFIED by '{$_SESSION['password']}'";
- $dbh->query($SQL2);
- $SQL3 = "GRANT all privileges ON {$_SESSION['dbname']}.* to '{$_SESSION['username']}'@'localhost' IDENTIFIED by '{$_SESSION['password']}'";
- $dbh->query($SQL3);
- echo "{$_SESSION['dbname']} was successfully created, now you can log into your database on Hive696 using the following line: <br>
- \"mysql -u{$_SESSION['username']} -p{$_SESSION['password']}\"";
- $dbh = null;
- }
- elseif (empty($_POST['username'])) //----------HERE-----------
- {
- echo 'Error';
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement