There are already threads explaining how to do this, not specifically your problem, but as you reported that is layman in language I will explain in response.
This is your code (apparently it’s working)
<?php
$login = $_POST['login'];
$entrar = $_POST['entrar'];
$senha = md5($_POST['senha']);
$connect = mysql_connect('xxxx','xxxxx','xxxxxxx');
$db = mysql_select_db('xxxxxxxxx');
if (isset($entrar)) {
$verifica = mysql_query("SELECT * FROM usuarios WHERE login = '$login' AND senha = '$senha'") or die("erro ao selecionar");
if (mysql_num_rows($verifica)<=0){
echo"<script language='javascript' type='text/javascript'>alert('Login e/ou senha incorretos');window.location.href='login.html';</script>";
die();
}else{
setcookie("login",$login);
header("Location:index.php");
}
}
?>
Along those lines $verifica = mysql_query("SELECT * FROM usuarios WHERE login = '$login' AND senha = '$senha'") or die("erro ao selecionar");
you are selecting everything from the table usuarios
where credentials are in agreement.
This query is bringing all the data from the table, as long as the entered data is ok.
Along those lines if (mysql_num_rows($verifica)<=0)
you are checking if the user does not exist on else
you are saving the login in a session, the logic is the same, just in the block of the else
add $fetch = mysql_fetch_object($verifica);
and access the value of points $fetch->pontos;
at the end your code would be
<?php
$login = $_POST['login'];
$entrar = $_POST['entrar'];
$senha = md5($_POST['senha']);
$connect = mysql_connect('xxxx','xxxxx','xxxxxxx');
$db = mysql_select_db('xxxxxxxxx');
if (isset($entrar)) {
$verifica = mysql_query("SELECT * FROM usuarios WHERE login = '$login' AND senha = '$senha'") or die("erro ao selecionar");
if (mysql_num_rows($verifica)<=0){
echo"<script language='javascript' type='text/javascript'>alert('Login e/ou senha incorretos');window.location.href='login.html';</script>";
die();
}else{
setcookie("login",$login);
$fetch = mysql_fetch_object($verifica);
$_SESSION["pontos"] = $fetch->pontos;
header("Location:index.php");
}
}
?>
To access the session value in index.php
just sign in to the file and get the value.
index php.
session_start();
echo "you have " . $_SESSION["points"] . " points";
Put the login code in the question so we can help you.
– user60252
Which code? From the entire login page?
– Thiago Vinícius
You want to show this score on the index.php page, correct?
– user60252
That, exactly.
– Thiago Vinícius
If you just want to get the value of points just reuse the query you did. $fetch = mysql_fetch_object($verifies); , and then display the value of points $fetch->points; , or store in a Session. I also state that using Mysqli or PDO as connection drive mysql_* no longer receives support.
– Mauro Alexandre
How would you do that, Mauro? I’m pretty layabout in PHP....
– Thiago Vinícius
If any answer solves your problem mark it as accepted. See how in https://i.stack.Imgur.com/jx7Ts.png and why in https://pt.meta.stackoverflow.com/questions/1078/como-e-por-que-aceitar-uma-resposta/1079#1079
– user60252
Enjoy a tour in https://answall.com/tour
– user60252