<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="style1.css">
<title></title>
</head>
<?php
require('connect.php');
if (isset($_POST['username']) && isset($_POST['password'])){
$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['password'];
$query = "INSERT INTO users (username, email, password) VALUES ('$username', '$email', '$password')";
$result = mysqli_query($connection, $query) ;
if($result){
$smsg = 'regissssttttrrr';
} else{
$fmsg = 'NOOOOOOOOOOOOOOOO';
}
}
?>
<body>
<div class="container">
<form method="post" class="form-signin">
<h2>Registration</h2>
<?php if(isset($smsg)){ ?><div class="alert alert-sucess" role="alert"> <?php echo $smsg; ?> </div><?php }?>
<?php if(isset($fmsg)){ ?><div class="alert alert-danger" role="alert"> <?php echo $fmsg; ?> </div><?php }?>
<input type="text" name="username" value="" placeholder="username" class="form-controll" required>
<input type="text" name="email" value="" placeholder="email" class="form-controll" required>
<input type="text" name="password" value="" placeholder="Password" class="form-controll" required>
<button class="btn-lg btn-primary btn-block"type="submit">Register</button>
<a href="login.php" class="btn btn-large btn-primary btn-block">login</a>
</form>
</div>
</body>
</html>
<?php
$connection = mysqli_connect('localhost', 'root', 'root');
$select_db = mysqli_select_db($connection, 'practice');
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="style1.css">
<title></title>
</head>
<body>
<div class="container">
<form method="post" class="form-signin">
<h2>LOGIN</h2>
<input type="text" name="username" value="" placeholder="username" class="form-controll" required>
<input type="text" name="password" value="" placeholder="Password" class="form-controll" required>
<button class="btn-lg btn-primary btn-block"type="submit">login</button>
<a href="index.php" class="btn btn-large btn-primary btn-block">Register</a>
</form>
</div>
<?php
session_start();
require('connect.php');
if (isset($_POST['username']) and isset($_POST['password'])){
$username = $_POST['username'];
$password = $_POST['password'];
$query = "SELECT * FROM users WHERE username='$username' and password='$password'";
$result = mysqli_query($connection, $query) or die(mysqli_error($connection));
$count = mysqli_num_rows($result);
if ($count == 1) {
$_SESSION['username'] = $username;
} else {
$fmsg = "Ощибка";
}
}
if (isset($_SESSION['username'])) {
$username = $_SESSION['username'];
echo "Hello" . $username . "";
echo "<a href='logout.php' class='btn btn-large btn-primary btn-block'>logout</a> ";
}
?>
</body>
</html>
<?php
session_start();
session_destroy();
header( 'Location index.php');
exit;
?>
даже не вылезает приветствие пользователя и значок логаута.
Самое забавное то, что когда-то он появлялся, а в коде с того момента я я ничего не менял.
Когда ввожу данные, делаю логин, ничего не добавляется в бд(мб так и должно быть
)
В регистрации всё впорядке