Basically, on my website, I was trying to create a login system and I did it and everything's fine until my alert box from bootstrap4 started returning my web file after logging in - return of my web file from the alert box: https://gyazo.com/aa21b2f0ae4d427348c0e35495de0c2e, and the actual web file: https://gyazo.com/29c4768bf0206feb667b9ab438f626bc
Sorry for not posting it in the image block but i needed to have at least 10 reputation points in order to do that and without them it will be hard to understand
I've tried undoing my actions but it still didn't help and the problem persists
I get 2 PHP notices:
PHP Notice: session_start(): A session had already been started - ignoring in (path)/action.php on line 46, referer: https://website.com/index.php
PHP Notice: Undefined index: username in (path)/session.php on line 6, referer: https://website.com/index.php
And the code that it refers to: Action.php
if (isset($_POST['action']) && $_POST['action'] == 'login') {
session_start(); // line 46 in action.php
$username = $_POST['username'];
$password = $_POST['password'];
Session.php
session_start();
require 'includes/config.php';
$user = $_SESSION['username']; // line 6 in session.php
$stmt = $connection->prepare("SELECT username, activetill FROM users WHERE username = ?");
$stmt->bind_param("s", $user);
$stmt->execute();
And the actual code that makes the alert box return something:
$("#login").click(function(e) {
if (document.getElementById('login-form').checkValidity()) {
e.preventDefault();
$("#loader").show();
$.ajax({
url: 'action.php',
method: 'post',
data: $("#login-form").serialize() + '&action=login',
success: function(response) {
if (response === "You\'ve been successfully logged in.") {
window.location = 'panel.php';
} else {
$("#alert").show();
$("#result").html(response);
$("#loader").hide();
}
}
});
}
return true;
});