add login

This commit is contained in:
nyosic 2025-01-22 20:55:10 +01:00
parent c38fcba442
commit 89d71a57e8
3 changed files with 109 additions and 0 deletions

33
php/login/log.css Normal file
View File

@ -0,0 +1,33 @@
* {
font-family: sans-serif;
}
#log1_html form {
margin-top: 10%;
margin-left: 20%;
line-height: 2em;
background-color: #888;
width: fit-content;
padding: 10px 25px;
}
#log1_html input:focus {
background: #aaa;
}
#log1_php table,#log1_php td,#log1_php th {
border: 2px navy solid;
border-collapse: collapse;
}
#log1_php td #log1_php th {
padding:2px 4px;
}
#log1_php tr:hover {
background-color: #333;
color: bisque;
}
#log1_php tr:last-child {
background-color: red;
color: aqua;
}
#log1_php input[type="submit"] {
margin-top:2%;
margin-left: 10%;
}

20
php/login/log1.html Normal file
View File

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./log.css">
</head>
<body>
<div id="log1_html">
<form action="log1.php" method="post">
<table>
<tr><td>User name:</td><td><input type="text" name="login" placeholder="wpisz login" onfocus="placeholder=''" onblur="placeholder='zapomniałeś o mnie'"></td></tr>
<tr><td>Password:</td><td><input type="password" name="haslo" placeholder="wpisz hasło" onfocus="placeholder=''" onblur="placeholder='gdzie hasło!!'"></td></tr>
</table>
<input type="submit" value="wyślij dane" name="p1">
</form>
</div>
</body>
</html>

56
php/login/log1.php Normal file
View File

@ -0,0 +1,56 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./log.css">
</head>
<body>
<div id="log1_php">
<?php
if(isSet($_POST['p1'])) {
$login = $_POST['login'];
$haslo = $_POST['haslo'];
$link = mysqli_connect("localhost","root","","bazahasel");
$q = mysqli_query($link,"SELECT * FROM user");
$q2 = mysqli_query($link,"SHOW COLUMNS from user;");
echo "użytkownik: ",$login;
$k=0;
while($row=mysqli_fetch_array($q)) {
if($login==$row['login'] and $haslo==$row['haslo']) $k=1;
}
if($k==1) {
$q = mysqli_query($link,"SELECT * FROM user");
echo"<h3>logowanie pomyślne!</h3>";
echo "<table>";
echo"<tr>";
while($row=mysqli_fetch_row($q2)){
echo "<th>$row[0]</th>";
}
echo"</tr>";
while($row=mysqli_fetch_row($q)) {
echo"<tr>";
for($i=0;$i<mysqli_num_fields($q);$i++)
echo "<td>$row[$i]</td>";
echo"</tr>";
}
echo "</table>";
echo'<form action="log1.html"><input type="submit" value="<===="></form>';
} else {
echo "<h3>logowanie nie powiodło się</h3>";
echo'<form action="log1.html"><input type="submit" value="<===="></form>';
header("Refresh: 5; url=log1.html");
}
}
else {
echo "błąd danych";
exit;
}
?>
</div>
</body>
</html>