Guest User

Untitled

a guest
Aug 31st, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. <?php
  2.  
  3. if (isset($_POST['connect'])){
  4.  
  5. $dbhost=htmlentities($_POST['dbhost']);
  6. $dbuser=htmlentities($_POST['dbuser']);
  7. $dbpass=htmlentities($_POST['dbpass']);
  8. $dbname=htmlentities($_POST['dbname']);
  9.  
  10. $connection=mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);
  11.  
  12. if(!$connection){
  13. die("No Connection" .mysqli_connect_error());
  14. }
  15. else{
  16. echo "connection Sucesfully";
  17. }
  18.  
  19. $sql="
  20. CREATE TABLE languages (
  21. id INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  22. rus TEXT(200) NOT NULL,
  23. eng TEXT(200) NOT NULL,
  24. pl TEXT(200) NOT NULL
  25. ),
  26. CREATE TABLE gallery (
  27. id INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  28. big_img VARCHAR(255) NOT NULL,
  29. middle_img VARCHAR(255) NOT NULL,
  30. small_img VARCHAR(255) NOT NULL
  31. )";
  32. if (mysqli_query($connection, $sql)) {
  33. echo "All Tables Created Successfully";
  34. } else {
  35. echo "Error creating table: " . mysqli_error($connection);
  36. }
  37.  
  38. mysqli_close($connection);
  39.  
  40. }
  41.  
  42.  
  43. ?>
  44. <!DOCTYPE html>
  45. <html>
  46. <head>
  47. <meta charset="utf-8">
  48. <title>Test</title>
  49. </head>
  50. </body>
  51.  
  52. <form action="<?php $_SERVER['PHP_SELF'];?>" method="post">
  53.  
  54. <input type="text" name="dbhost" placeholder="Enter Host Name">
  55. </br>
  56. <input type="text" name="dbuser" placeholder="Enter Database User Name">
  57. </br>
  58. <input type="password" name="dbpass" placeholder="Enter Database Password">
  59. </br>
  60. <input type="text" name="dbname" placeholder="Enter Database Name">
  61. </br>
  62. <button type="submit" name="connect" value="send">Connect Database</button>
  63.  
  64.  
  65.  
  66. </form>
  67. </body>
  68. </html>
Add Comment
Please, Sign In to add comment