Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // $sql = "INSERT INTO `users` (`id`, `account`, `password`, `created`) VALUES (NULL, \'hoi\', \'hoi\', CURRENT_TIMESTAMP)";
- // $sql = SELECT * FROM `users` WHERE `account` = "hoi" AND `password` = "hoi";
- // $sql = SELECT * FROM `users` WHERE `account` = "$_POST["username"]" AND `password` = "$_POST["password"]";
- // $render = " ";
- // $servername = "localhost";
- // $username = "root";
- // $password = "";
- // $dbname = "project1_db";
- // $query = "SELECT * FROM `user` WHERE username='$username' and password='$password'";
- // // Create connection
- // $conn = new mysqli($servername, $username, $password, $dbname);
- // // Check connection
- // if (!$conn) {
- // die("Connection failed: " . mysqli_connect_error());
- // }
- // $sql = "SELECT `id`, `account`, `password`, `created` FROM users";
- // $result =mysqli_query($conn, $sql);
- // if (mysqli_num_rows($result) > 0) {
- // // output data of each row
- // while($row = mysqli_fetch_assoc($result)) {
- // $render = "<dr>id: " . $row["id"]. " Username: " . $row["account"]. " Password: " . $row["password"]. " Timestamp: " .$row["created"]. "<br>";
- // }
- // } else {
- // $render = "0 results";
- // }
- function logon() {
- $result = " ";
- if (isset($_POST["logoff"])) {
- //unset($_SESSION);
- //$_SESSION = array();
- //session_destroy();
- session_unset();
- }
- if (isset($_POST['logon']) && $_POST['username']== "UR USERNAME" && $_POST['Password']== "UR PASSWORD")
- {
- $_SESSION['logon'] = true;
- }
- if (isset($_SESSION['logon']) == true) {
- $form = '<form action="" method="post">';
- $form .= '<div class="modal-inner">';
- $form .= '<input type="submit" name="logoff" value="logoff">';
- $form .= '</div></form>';
- }
- else {
- $form = '<form action="" method="post">';
- $form .= '<table><tbody>';
- $form .= '<h2>Login</h2><br>';
- $form .= '<tr><td><input type="text" name="username" placeholder="Username"><br></td></tr>';
- $form .= '<tr><td><input type="password" name="Password" placeholder="Password"><br></td></tr>';
- $form .= '<tr>';
- $form .= '<td><input type="submit" name="logon" value="Login"></td>';
- $form .= '</tr></table></tbody></form>';
- }
- return $result . $form;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement