There is already a thread explaining how to do this, not specifically your problem, but as you said you are a layperson in the language I will explain how to answer.
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");
}
}
?>
In this line $verifica = mysql_query("SELECT * FROM usuarios WHERE login = '$login' AND senha = '$senha'") or die("erro ao selecionar");
you are selecting everything from the usuarios
table where the credentials are in agreement.
This query is bringing all the data in the table as long as the data you entered is ok.
In this line if (mysql_num_rows($verifica)<=0)
you are checking if the user does not exist, in the else
you are saving the login in a session, the logic is the same, just block else
add $fetch = mysql_fetch_object($verifica);
and access the value of points $fetch->pontos;
In 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
simply log in to the file and get the value.
index.php
session_start ();
echo "you have". $ _SESSION ["points"]. "points";