I have already made registration and login pages for my web page. The question is that I want to display the name and the image of the user after login, in other words, I want to make some changes in my main page after login.
So this is my code:
lib.php
function checkUser($username,$password){
include "connection.php";
$result = mysqli_query($conn, "SELECT * FROM `data` WHERE `username` = '$username' AND `password` = '$password'") or die("No result".mysqli_error());
$row = mysqli_fetch_array($result);
$logic = false;
if (($row['username'] == $username) && ($row['password'] == $password)) {
echo "Login is successfull. Welcome <b>".$row['username']."</b>";
$logic = true;
}
else{
echo "Failed to login. Username or password is incorrect. Try again.";
}
return $logic;
}
function logIn($username, $password){
include ("connection.php");
$_SESSION["loggedInUser"] = $username;
$_SESSION["loggedInTime"] = time();
}
action.php
<?php
include "lib.php";
if(checkUser($username,$password)){
logIn($username, $password);
header("Location: index_en.php");//goes to my main page
?>
<li><a href="#">Hello, <?php echo $username; ?></a></li>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
console.log("successfull");
$(".nav_header").remove();//I tried to change my index_en.php page, but no changes appear there
</script>
<?php
}
?>