thank you for reading my message. I am working on a website, but whenever I want to display a number from a database field on the website, no errors, but nothing is shown.
(sorry for bad english)
auth
session_start();
if(!isset($_SESSION["username"])) {
header("Location: login.php");
exit();
}
login
require('db.php');
session_start();
// When form submitted, check and create user session.
if (isset($_POST['username'])) {
$username = stripslashes($_REQUEST['username']); // removes backslashes
$username = mysqli_real_escape_string($con, $username);
$password = stripslashes($_REQUEST['password']);
$password = mysqli_real_escape_string($con, $password);
// Check user is exist in the database
$query = "SELECT * FROM `users` WHERE username='$username'
AND password='" . md5($password) . "'";
$result = mysqli_query($con, $query) or die(mysql_error());
$rows = mysqli_num_rows($result);
if ($rows == 1) {
$_SESSION['username'] = $username;
$_SESSION['coins'] = $coins;
// Redirect to user dashboard page
header("Location: dashboard-2.php");
} else {
echo "<div class='form'>
<h3>Je wachtwoord of gebruikersnaam is onjuist.</h3><br/>
<p class='link'>Klik hier om <a href='login.php'>terug</a> te gaan.</p>
</div>";
}
} else {
coins need to be shown on the dashboard.