Advertisement
Guest User

setting_db/index.php

a guest
Jun 9th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.54 KB | None | 0 0
  1. <?php
  2. if (file_exists('../config/setting.php')) {
  3.     include "../config/setting.php";
  4.     $koneksi = new mysqli($host,$user,$pass,$db);
  5.     if ($koneksi->connect_error) {
  6.         unlink('../config/setting.php');
  7.         header("location: setting_db/");
  8.     }else {
  9.         echo "Anda Sudah Pernah Menyettingnya Jika Ingin Menyetting Ulang Maka Hapus Database dan File setting.php ";
  10.     }
  11. }else {
  12. ?>
  13.  
  14. <title>Setting Database</title>
  15. <link href="assets/bootstrap.min.css" rel="stylesheet" type="text/css">
  16. <body style="margin:15% auto;width:250px;">
  17.     <center>
  18.         <form method="POST" enctype="multipart/form-data">
  19.             <div class="form-group">               
  20.             <input class="form-control" type="text" name="a" value="localhost">
  21.             </div>
  22.             <div class="form-group">               
  23.             <input class="form-control" type="text" name="b" placeholder="username">
  24.             </div>
  25.             <div class="form-group">               
  26.             <input class="form-control" type="text" name="c" placeholder="password">
  27.             </div>
  28.             <div class="form-group">               
  29.             <input class="form-control" type="text" name="d" placeholder="database">
  30.             </div>
  31.             <div class="form-group">
  32.             <input class="form-control" type="submit" name="input" value="Save">
  33.             </div>                                             
  34.         </form>
  35.     </center>
  36. </body>
  37. <?php  
  38. if (isset($_POST['input'])) {
  39. file_put_contents('../config/setting.php',
  40. '<?php  
  41. $host = "'.htmlspecialchars($_POST['a']).'";
  42. $user = "'.htmlspecialchars($_POST['b']).'";
  43. $pass = "'.htmlspecialchars($_POST['c']).'";
  44. $db = "'.htmlspecialchars($_POST['d']).'";
  45. ?>'
  46. );
  47. header("location: install.php");
  48. }
  49. ?>
  50.  
  51. <?php  
  52. }
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement