Я написал форму входа, используя bootstrap, и у меня проблема из-за того, что массив сообщений не получает значения на стороне PHP. Я видел, что если я не использую класс карты, форма работает, но я хочу поместить форму внутри этого класса по причинам стилизации.
Вот форма входа:
Адрес электронной почты для входа пользователя Пароль Отправить Зарегистрировать аккаунт Забыли пароль?
включение / вход. php
session_start();
//database connection details
$DATABASE_HOST = 'localhost'; // sql100.epizy.com
$DATABASE_USER = 'japster';
$DATABASE_PASS = 'IUs2M4ql2aEbV';
$DATABASE_NAME ='83west';
//try connecting with the above info
$con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);
/* used to test my connection and it works, there is a connection to the db
if ($con->connect_error){
die("Connection to database failed: ". $con->connect_error);
}
else {
echo "success";
}*/
if (isset($_POST['submit'])){
// Now we check if the data from the login form was submitted, isset() will check if the data exists.
if ( !isset($_POST['email'], $_POST['password']) ) {
// Could not get the data that should have been sent.
exit('Please fill both the username and password fields!');
}
// Prepare our SQL, preparing the SQL statement will prevent SQL injection.
if ($stmt = $con->prepare('SELECT email, password FROM user WHERE email = ?')) {
// Bind parameters (s = string, i = int, b = blob, etc), in our case the username is a string so we use "s"
$stmt->bind_param('s', $_POST['email']);
$stmt->execute();
// Store the result so we can check if the account exists in the database.
$stmt->store_result();
if ($stmt->num_rows > 0) {
$stmt->bind_result($email, $password);
$stmt->fetch();
// Account exists, now we verify the password.
// Note: remember to use password_hash in your registration file to store the hashed passwords.
if (password_verify($_POST['password'], $password)) {
// Verification success! User has loggedin!
// Create sessions so we know the user is logged in, they basically act like cookies but remember the data on the server.
session_regenerate_id();
$_SESSION['loggedin'] = TRUE;
$_SESSION['name'] = $_POST['email'];
echo 'Welcome ' . $_SESSION['email'] . '!';
} else {
echo 'Incorrect password!';
}
} else {
echo 'Incorrect username!';
}
$stmt->close();
}
}
Код просто никогда не попадает в:
if (isset($_POST['submit'])){
, даже если у меня есть данные в таблица или нет данных в таблице, ничего не происходит, он просто переходит в файл include / login. php и останавливается там, не давая мне сообщения об ошибке, что пароль или адрес электронной почты использовались, даже когда данные, которые я ввел не существует.
Эта проблема возникала раньше, когда я пытался поместить форму внутри div с классом карты
<div class="card" style="width: 18rem;">