Wednesday, 2017-11-22, 1:38 AM
Main
Registration
Login
RaDIo^^ZoNe
Welcome Guest | RSS
[ New messages · Members · Forum rules · Search · RSS ]
Page 1 of 11
Forum » TUTORIAL ZONE » Diferite tutoriale » script autentificare
script autentificare
radio-zoneDate: Thursday, 2008-08-14, 3:18 PM | Message # 1
Admin
Group: Administrators
Messages: 11
Reputation: 0
Status: Offline
Script Autetificare Simplu


Code
session_start();
//sectiune Autetinficare baza de date
$BAZA['utilizator']="root";
$BAZA['parola']="";
$BAZA['server']="localhost";
$BAZA['baza']="login";
mysql_connect($BAZA['server'],$BAZA['utilizator'],$BAZA['parola']);
mysql_select_db($BAZA['baza']) or die("baza");

// Sectiunea de autentificare
function auth()
{
    $_SESSION['AUTH'] = 1;
    header('HTTP/1.0 401 Unauthorized');
    header('WWW-Authenticate: Basic realm="Autentificare in sistem"');
    //In cazul in care nu sa dat cancel sau datele nu sunt corecte
    echo'<html>
         <head>
         <meta http-equiv="Content-Language" content="en-us">
         <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
         <meta name="ProgId" content="FrontPage.Editor.Document">
         <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
         <title>/!\Accesul interzis!!!</title>
        </head>
        <body>
        <center>
        <p> </p>
        <p> </p>
        <table border="5" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#FF0000" width="86%" id="AutoNumber1" height="222">
         <tr>
           <td width="100%" height="222">
             <p align="center"><font color="#FF0000"><font style="font-size: 70pt">Accesul</font><font style="font-size: 70pt"> interzis!!!!!</font></font></td>
        </tr>
        </table>
        </center>
        </body>
        </html>';
    exit;
}

if (!isset($_SESSION['sesiune'])) {

//Verific daca seisuna sau parola si userul sunt completate
if( !isset($_SERVER['PHP_AUTH_USER']) or @$_SESSION['AUTH'] != 1 )
{
    auth();
   }
//variabile user si pass
$user=$_SERVER['PHP_AUTH_USER'];
$pass=$_SERVER['PHP_AUTH_PW'];
//Verific si informez daca nu sa completat utilizator
if ( $user == "" ) {
     auth();
}
//Verific si informez daca nu sa completat parola
if ( $pass == "" ) {
       auth();
}
//Verifica daca utilizatorul si parola este corecta
$dbv=mysql_query("select * from `utilizator` where `pseudonim`='".$user."' and `parola`='".$pass."'");
$nrv=mysql_numrows($dbv);
if ( $nrv > 0 ) {
//Creare informatii despre persona care sa autentificat
//-----------------------------------------------------
//Declar user
   $_SESSION['user']=$user;
//Preluam nume/prenume
   $_SESSION['sesiune']=session_id();
//Preluam nivelul utilizatorului
   $_SESSION['nivel']=mysql_result($dbv,0,"nivelacc") ;
//Preluat Id tuilizator
   $_SESSION['idp']=mysql_result($dbv,0,"id") ;
} else{auth();}
}



[hr]
 
Forum » TUTORIAL ZONE » Diferite tutoriale » script autentificare
Page 1 of 11
Search:


| Copyright MyCorp © 2017 | |