signin.php:
<?php
include("config.php");
if (mysqli_connect_errno())
{
echo "MySQLi Connection was not established: " . mysqli_connect_error();
}
if(isset($_POST['login']))
{
$username = mysqli_real_escape_string($con,$_POST['username']);
$password = mysqli_real_escape_string($con,$_POST['password']);
$sel_user = "SELECT * FROM user WHERE username='$username' AND password='$password'";
$run_user = mysqli_query($con, $sel_user);
$check_user = mysqli_num_rows($run_user);
if($check_user = 2)
{
$_SESSION['username']=$username;
echo "<script>window.open('index.php','_self')</script>";
}
else
{
echo "<script>alert('Email or password is not correct, try again')</script>";
}
}
?>
index.php:
<ul class="nav navbar-nav navbar-right">
<li><a href="mypage.html">My Page</a></li>
<li><a href="signup.php">Sign up</a></li>
<li><a href="signin.php">Sign in</a></li>
</ul>
So, there are three options in my index.php, My Page, Sign up, and Sign in. I want to change Sign in to Sign out when user logs in and display my name on the left side of My Page option. How can I modify my codes? please don't just say "You need ~~~". please indicate where exactly add it as well. Thank you