Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.05 KB | None | 0 0
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3.     <head>
  4.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5.         <title>Login page</title>
  6.     </head>
  7.     <body>
  8.         <center><h3>Enter your credentials</h3></center>
  9.  
  10.         <form name="Form1" method="post" action="index.php">
  11.  
  12.         Username: <input type="text" name="username" />
  13.         Password: <input type="text" name="password" />
  14.         DB Name: <input type="text" name="dbname" />
  15.         <input type="submit" name="submit" />
  16.         </form>
  17.        
  18.         <?php   session_start();
  19.             if (isset($_POST['username']) && isset($_POST['password']) && isset($_POST['dbname']))
  20.             {
  21.                 $_SESSION['dbname'] = $_POST['dbname'];
  22.                 $_SESSION['username'] = $_POST['username'];
  23.                 $_SESSION['password'] = $_POST['password'];
  24.              
  25.                 $dsn = 'mysql:host=localhost';
  26.                 $user = 'root';
  27.                 $password = 'ONGOINGwarfare1+2+3+';
  28.                 try {
  29.                     $dbh = new PDO($dsn, $user, $password);
  30.                 } catch (PDOException $e) {
  31.                     echo 'Connection failed : ' , $e->getMessage();
  32.                 }
  33.  
  34.                 $SQL1 = "CREATE DATABASE {$_SESSION['dbname']}";
  35.                 $dbh->query($SQL1);
  36.                 $SQL2 = "CREATE USER {$_SESSION['username']} IDENTIFIED by '{$_SESSION['password']}'";
  37.                 $dbh->query($SQL2);
  38.                 $SQL3 = "GRANT all privileges ON {$_SESSION['dbname']}.* to '{$_SESSION['username']}'@'localhost' IDENTIFIED by '{$_SESSION['password']}'";
  39.                 $dbh->query($SQL3);
  40.                
  41.                 echo "{$_SESSION['dbname']} was successfully created, now you can log into your database on Hive696 using the following line: <br>
  42.                        \"mysql -u{$_SESSION['username']} -p{$_SESSION['password']}";
  43.                 $dbh = null;
  44.             }
  45.             //include ("dashboard.php");
  46.         ?>
  47.     </body>
  48. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement