Advertisement
Guest User

Untitled

a guest
Jul 9th, 2018
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "username";
  4. $passwd = "password";
  5. $dbname = "myDB";
  6.  
  7. // Create connection
  8. $conn = new mysqli($servername, $username, $passwd, $dbname);
  9. // Check connection
  10. if ($conn->connect_error) {
  11.     die("Connection failed: " . $conn->connect_error);
  12. }
  13.  
  14. $username = $_POST['user'];
  15. $password = $_POST['pass'];
  16.  
  17. $query = mysql_query(INSERT INTO admin (username, password) VALUES('oji', 'admin123');
  18. $data = mysql_fetch_array($query);
  19.  
  20. if ($data['jumlah'] >= 1){
  21.     session_start();
  22.     $_SESSION['username']    = $username;
  23.     $_SESSION['password']    = $password;
  24.  
  25.     echo "<script>alert('Selamat datang $username'); window.location = 'admin/tambah.php'</script>";  
  26. } else {
  27.     echo "<script>alert('Username dan Password tidak valid.'); window.location = 'index.html'</script>";  
  28. }
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement