Advertisement
Guest User

Untitled

a guest
Sep 11th, 2017
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. <?php
  2. //session_start();
  3. //$errorMsg = "";
  4. //
  5. //if (isset($_SESSION["login"]) == true) {
  6. // header("Location: success.php");
  7. //} else {
  8. // if (isset($_POST["sub"])) {
  9. //
  10. // $validUser = $_POST["username"] == "admin" AND $_POST["password"] == "password";
  11. // if (!$validUser) {
  12. // echo $errorMsg = "Invalid username or password.";
  13. // } else {
  14. // $_SESSION["login"] = true;
  15. // header("Location: success.php");
  16. // }
  17. // }
  18. //}
  19. $host = "localhost";
  20. $user = "root";
  21. $password = "";
  22. $database = "abc";
  23.  
  24. $sql = mysqli_connect($host, $user, $password, $database);
  25. if (isset($_POST["sub"])) {
  26. if ($sql) {
  27. $username = $_POST['username'];
  28. $pass = $_POST['password'];
  29.  
  30. $insrt = "INSERT INTO `abc`.`users` ( `ID` , `name` , `pass` ) VALUES ( NULL , '$username','$pass' )";
  31. mysqli_query($sql, $insrt);
  32. echo mysqli_error($sql);
  33. } else {
  34. echo 'Not Connect';
  35. }
  36. }
  37.  
  38. $select = "SELECT * FROM `users`";
  39. $select = mysqli_query($sql, $select);
  40.  
  41. if (isset($_POST["delete"])) {
  42. $id = $_POST['Did'];
  43.  
  44. $dlt = "DELETE FROM `users` where id=$id";
  45. mysqli_query($sql, $dlt);
  46. }
  47. ?>
  48. <!DOCTYPE html>
  49. <html>
  50. <head>
  51. <meta http-equiv="content-type" content="text/html;charset=utf-8" />
  52. <title>Login</title>
  53. </head>
  54. <body>
  55. <form name="input" action="" method="post">
  56. <label for="username">Username:</label><input type="text" value="" id="username" name="username" />
  57. <label for="password">Password:</label><input type="password" value="" id="password" name="password" />
  58. <!--<div class="error"><?= $errorMsg ?></div>-->
  59. <input type="submit" value="Home" name="sub" />
  60. </form>
  61.  
  62. <table border="2">
  63. <tr>
  64. <th>Name</th>
  65. <th>Pass</th>
  66. <th>active</th>
  67. </tr>
  68. <?php
  69. $total = 0;
  70. $i = 0;
  71. while ($rows = mysqli_fetch_assoc( $select)) {
  72. ?>
  73. <tr>
  74. <td><?php echo $i + 1; ?></td>
  75. <td><?php echo $rows['name']; ?></td>
  76. <td><?php echo $rows['pass']; ?></td>
  77. <td><a href="abc.php?id=<?php echo $rows['id']; ?>">Edit</a>
  78. <a href="">View</a>
  79.  
  80. <form action="" method="post">
  81. <input type="hidden" name="Did" value="<?php echo $rows['id']; ?>" />
  82. <input type="submit" name="delete" value="Delete" />
  83. </form>
  84. </td>
  85. </tr><?php
  86. $total++;
  87. $i++;
  88. }
  89. ?>
  90. <tr>
  91. <th>Total User : </th>
  92. <td colspan="3"><?php echo $total; ?></td>
  93. </tr>
  94. </table>
  95. </body>
  96. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement