Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //session_start();
- //$errorMsg = "";
- //
- //if (isset($_SESSION["login"]) == true) {
- // header("Location: success.php");
- //} else {
- // if (isset($_POST["sub"])) {
- //
- // $validUser = $_POST["username"] == "admin" AND $_POST["password"] == "password";
- // if (!$validUser) {
- // echo $errorMsg = "Invalid username or password.";
- // } else {
- // $_SESSION["login"] = true;
- // header("Location: success.php");
- // }
- // }
- //}
- $host = "localhost";
- $user = "root";
- $password = "";
- $database = "abc";
- $sql = mysqli_connect($host, $user, $password, $database);
- if (isset($_POST["sub"])) {
- if ($sql) {
- $username = $_POST['username'];
- $pass = $_POST['password'];
- $insrt = "INSERT INTO `abc`.`users` ( `ID` , `name` , `pass` ) VALUES ( NULL , '$username','$pass' )";
- mysqli_query($sql, $insrt);
- echo mysqli_error($sql);
- } else {
- echo 'Not Connect';
- }
- }
- $select = "SELECT * FROM `users`";
- $select = mysqli_query($sql, $select);
- if (isset($_POST["delete"])) {
- $id = $_POST['Did'];
- $dlt = "DELETE FROM `users` where id=$id";
- mysqli_query($sql, $dlt);
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="content-type" content="text/html;charset=utf-8" />
- <title>Login</title>
- </head>
- <body>
- <form name="input" action="" method="post">
- <label for="username">Username:</label><input type="text" value="" id="username" name="username" />
- <label for="password">Password:</label><input type="password" value="" id="password" name="password" />
- <!--<div class="error"><?= $errorMsg ?></div>-->
- <input type="submit" value="Home" name="sub" />
- </form>
- <table border="2">
- <tr>
- <th>Name</th>
- <th>Pass</th>
- <th>active</th>
- </tr>
- <?php
- $total = 0;
- $i = 0;
- while ($rows = mysqli_fetch_assoc( $select)) {
- ?>
- <tr>
- <td><?php echo $i + 1; ?></td>
- <td><?php echo $rows['name']; ?></td>
- <td><?php echo $rows['pass']; ?></td>
- <td><a href="abc.php?id=<?php echo $rows['id']; ?>">Edit</a>
- <a href="">View</a>
- <form action="" method="post">
- <input type="hidden" name="Did" value="<?php echo $rows['id']; ?>" />
- <input type="submit" name="delete" value="Delete" />
- </form>
- </td>
- </tr><?php
- $total++;
- $i++;
- }
- ?>
- <tr>
- <th>Total User : </th>
- <td colspan="3"><?php echo $total; ?></td>
- </tr>
- </table>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement