1
I have a table in my DB with the following columns : User , Password , Level and I need to make each level related to the person be redirected to different pages . How can I accomplish that ?
Follow my line of code :
conexão.login.php
<?php
session_start();
$serverName = "";
$connectionInfo = array( "Database"=>"", "UID"=>"", "PWD"=>"" );
$conn = sqlsrv_connect($serverName, $connectionInfo);
if ($conn === false) {
die(print_r(sqlsrv_errors(), true));
}
$user = $_POST['email'];
$password = $_POST['password'];
$query = ("SELECT * FROM COLUNA WHERE LOGIN LIKE '$user' AND SENHA LIKE '$password'");
$params = array();
$options = array('Scrollable' => SQLSRV_CURSOR_KEYSET);
$stmt = sqlsrv_query($conn, $query, $params, $options);
$row_count = sqlsrv_num_rows($stmt);
if ($row_count > 0) {
$dados = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC);
$_SESSION['email'] = $user;
$_SESSION['password'] = $password;
$_SESSION['nivel'] = $dados["NIVEL"];
if( $_SESSION['nivel'] = 11){
header('location:x.php');
}
else{
header('location:y.php');
}}
else {
//Destrói
session_destroy();
//Limpa
unset ($_SESSION['email']);
unset ($_SESSION['password']);
unset ($_SESSION['nivel']);
//Redireciona para a página de autenticação
header('location:index.php');
}
?>
Thank you very much :) It worked perfectly.
– Foloni