Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $conn = new mysqli("localhost", "root", "", "abcd"); //"baza.nekaj.si", "root", "root", "abcd");
- if($conn->connect_error)
- die("fail". $conn->connect_error);
- $conn->set_charset("UTF-8");
- if (!isset($_SESSION["cnt"]))
- $_SESSION["cnt"] = 0;
- if (!isset($_SESSION["logged"]))
- $_SESSION["logged"] = FALSE;
- if (isset($_GET["submit"]) && $_SESSION["logged"] == FALSE) {
- $sql = "SELECT uporabnik, geslo, statusUporabnika, id FROM uporabnik WHERE uporabnik = '". $_GET["username"]. "' AND geslo = '" . $_GET["password"] ."';";
- $result = $conn->query($sql);
- echo $conn->error;
- if($result->num_rows == 0) {
- $_SESSION["cnt"]++;
- }
- else {
- $row = $result->fetch_assoc();
- $sql = "UPDATE uporabnik SET datumZadnjegaDostopa = ". date("Y-m-d") ." WHERE id = ".$row["id"].";";
- $_SESSION["logged"] = TRUE;
- logged($row["statusUporabnika"]);
- }
- }
- if (isset($_GET["delete"])) {
- $sql = "DELETE FROM uporabnik WHERE id = ". $_GET["cbox"].";";
- $conn->query($sql);
- }
- if($_SESSION["cnt"] > 3) {
- header("Location: www.yahoo.com");
- die();
- }
- if ($_SESSION["logged"]==FALSE) {
- echo '<form>
- uporabnisko ime <input type="text" name="username"><br>
- password <input type="password" name="password"><br>
- <input type="submit" name="submit" value="submit">
- </form>';
- }
- function logged($state) {
- global $conn;
- $sql = "SELECT uporabnik, id, datumZadnjegaDostopa FROM uporabnik;";
- $result = $conn->query($sql);
- echo "<form><table>";
- if ($result->num_rows > 0) {
- while($row = $result->fetch_assoc()) {
- echo "<tr>";
- echo "<td>". $row["uporabnik"]."</td><td>".$row["datumZadnjegaDostopa"]."</td>";
- if(strtotime($row["datumZadnjegaDostopa"]) < strtotime("-30 days"))
- if($state == "upravitelj")
- echo '<td><input type="radio" name="cbox" value="'.$row["id"].'"></td>';
- echo "</tr>";
- }
- }
- if ($state == "upravitelj")
- echo '<input type="submit" name="delete" value="delete">';
- echo "</table></form>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement