L'authentification via les info d'une BDD MySQL Hitskin_logo Hitskin.com

Ceci est une prévisualisation d'un thème de Hitskin.com
Installer le thèmeRetourner sur la fiche du thème

Club Informatique VINCI
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
Rechercher
 
 

Résultats par :
 


Rechercher Recherche avancée

Connexion

Récupérer mon mot de passe

Sondage

Quel est votre antivirus préféré ?

L'authentification via les info d'une BDD MySQL Vote_lcap16%L'authentification via les info d'une BDD MySQL Vote_rcap 16% [ 4 ]
L'authentification via les info d'une BDD MySQL Vote_lcap32%L'authentification via les info d'une BDD MySQL Vote_rcap 32% [ 8 ]
L'authentification via les info d'une BDD MySQL Vote_lcap0%L'authentification via les info d'une BDD MySQL Vote_rcap 0% [ 0 ]
L'authentification via les info d'une BDD MySQL Vote_lcap0%L'authentification via les info d'une BDD MySQL Vote_rcap 0% [ 0 ]
L'authentification via les info d'une BDD MySQL Vote_lcap0%L'authentification via les info d'une BDD MySQL Vote_rcap 0% [ 0 ]
L'authentification via les info d'une BDD MySQL Vote_lcap36%L'authentification via les info d'une BDD MySQL Vote_rcap 36% [ 9 ]
L'authentification via les info d'une BDD MySQL Vote_lcap0%L'authentification via les info d'une BDD MySQL Vote_rcap 0% [ 0 ]
L'authentification via les info d'une BDD MySQL Vote_lcap0%L'authentification via les info d'une BDD MySQL Vote_rcap 0% [ 0 ]
L'authentification via les info d'une BDD MySQL Vote_lcap8%L'authentification via les info d'une BDD MySQL Vote_rcap 8% [ 2 ]
L'authentification via les info d'une BDD MySQL Vote_lcap8%L'authentification via les info d'une BDD MySQL Vote_rcap 8% [ 2 ]

Total des votes : 25

Derniers sujets
» algorithme en langage C
L'authentification via les info d'une BDD MySQL EmptyJeu 28 Nov - 8:07 par arsenepoutsi

» CCNA version 4 français
L'authentification via les info d'une BDD MySQL EmptyDim 31 Mar - 15:15 par kadhouceeee

» Trés important " Livre exercices en langage C ( claude delannoy) "
L'authentification via les info d'une BDD MySQL EmptyJeu 27 Sep - 16:31 par latifa oustouh

» Ulead VideoStudio 11.5.0157.2 Plus + Crack Collection
L'authentification via les info d'une BDD MySQL EmptyJeu 26 Avr - 9:51 par miloduvi

» Langage IDL(Interface Definition Language)
L'authentification via les info d'une BDD MySQL EmptyMar 27 Sep - 13:02 par Abdelkhalek Bakkari

» demande cours PHP
L'authentification via les info d'une BDD MySQL EmptyJeu 2 Juin - 11:23 par elasriahmed

» exemple page web réaliser avec du html et JavaScript
L'authentification via les info d'une BDD MySQL EmptyLun 30 Mai - 4:05 par ouh.rouchan.zakaria

» cours group2_ 2année 2011
L'authentification via les info d'une BDD MySQL EmptyDim 20 Mar - 15:35 par El Maligno Angelo

» Cours : Infrastructures Réseaux 2003 Server
L'authentification via les info d'une BDD MySQL EmptyMar 15 Fév - 6:55 par jettjackson

» cours officiel de CCNA 2
L'authentification via les info d'une BDD MySQL EmptyMar 18 Jan - 13:53 par agares

Qui est en ligne ?
Il y a en tout 5 utilisateurs en ligne :: 0 Enregistré, 0 Invisible et 5 Invités

Aucun

[ Voir toute la liste ]


Le record du nombre d'utilisateurs en ligne est de 27 le Lun 3 Juin - 10:16
Statistiques
Nous avons 437 membres enregistrés
L'utilisateur enregistré le plus récent est intellection

Nos membres ont posté un total de 1292 messages dans 373 sujets
Le deal à ne pas rater :
Réassort du coffret Pokémon 151 Électhor-ex : où l’acheter ?
Voir le deal

L'authentification via les info d'une BDD MySQL

3 participants

Aller en bas

L'authentification via les info d'une BDD MySQL Empty L'authentification via les info d'une BDD MySQL

Message par El Maligno Angelo Lun 15 Juin - 15:15

Prérequis : La connexion avec une base de données MySQL

Au début du code de la page d'index (qui contient le formulaire d'authentification), on introduit connect.php (à préparer au préalable)
Code:
<?php require_once('Connections/connect.php'); ?>
On ouvre la session, par la suite on ouvre la connexion avec la base de donnée et on lance la requête sur la table qui contient les utilisateurs. Si les informations sont valides, on crée les variables de session s'il ne l'ai pas déjà. Puis on redirige l'utilisateur vers la page welcome.php.
Code:

<?php
if (!isset($_SESSION)) {
  session_start();
}

if (isset($_POST['txtNom'])) {
  $loginUsername=$_POST['txtNom'];
  $password=$_POST['txtPw'];
  $MM_redirectLoginSuccess = "accueil.php";
  $MM_redirectLoginFailed = "index.php?not_loged=true";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_connect, $connect);
 
  $LoginRS__query=sprintf("SELECT Login, Password FROM utilisateur WHERE Login='%s' AND Password='%s'",
    get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));
 
  $LoginRS = mysql_query($LoginRS__query, $connect) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);

  if ($loginFoundUser) {

    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;        
   
   //Keep session for one month
   if(!isset($_COOKIE['info'])&& isset($_POST['chkGarder'])){
      $info=array($_POST['txtNom'],$_POST['txtPw']);
      setcookie("info",implode(":",$info),time()+3600*24*30);
   }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>


Dernière édition par El Maligno Angelo le Ven 17 Juil - 14:39, édité 2 fois
El Maligno Angelo
El Maligno Angelo
Administrateur
Administrateur

Messages : 373
Points : 6370
Réputation : 8
Date d'inscription : 25/04/2009
Age : 35
Localisation : ErRabat

https://ci-vinci.forum-actif.net

Revenir en haut Aller en bas

L'authentification via les info d'une BDD MySQL Empty Re: L'authentification via les info d'une BDD MySQL

Message par mustang Mar 16 Juin - 4:50

Elles font quoi ces lignes ?
Code:
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));
mustang
mustang
Membre actif
Membre actif

Messages : 76
Points : 5770
Réputation : 6
Date d'inscription : 26/04/2009

Revenir en haut Aller en bas

L'authentification via les info d'une BDD MySQL Empty Re: L'authentification via les info d'une BDD MySQL

Message par El Maligno Angelo Mar 16 Juin - 9:52

C'est une sorte de protection contre l'injection SQL. La méthode get_magic_quotes_gpc() verifie si la protection des guillemets(par des slashes " => /" ) est activée ou non. S'il est activée, on utilise nos variable sans risque, sinon, on les protège avec addslashes() (c'est le rôle du if immédiat utilisé...).

à vos questions Very Happy
El Maligno Angelo
El Maligno Angelo
Administrateur
Administrateur

Messages : 373
Points : 6370
Réputation : 8
Date d'inscription : 25/04/2009
Age : 35
Localisation : ErRabat

https://ci-vinci.forum-actif.net

Revenir en haut Aller en bas

L'authentification via les info d'une BDD MySQL Empty Re: L'authentification via les info d'une BDD MySQL

Message par owenho Sam 19 Sep - 19:30

quelle est le role de sprintf et get_magic_quotes_gpc() et pardon pour le derangement Very Happy .


Code:
$LoginRS__query=sprintf("SELECT Login, Password FROM utilisateur WHERE Login='%s' AND Password='%s'",
    get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));
owenho
owenho
Modérateur
Modérateur

Messages : 115
Points : 5744
Réputation : 4
Date d'inscription : 02/05/2009
Age : 34
Localisation : larache/rabat

Revenir en haut Aller en bas

L'authentification via les info d'une BDD MySQL Empty Re: L'authentification via les info d'une BDD MySQL

Message par El Maligno Angelo Sam 19 Sep - 19:33

1/-sprintf = printf avec des amélioration de sécurité
2/-get_magic_quotes_gpc() voir la réponse just au deçu de ta question
El Maligno Angelo
El Maligno Angelo
Administrateur
Administrateur

Messages : 373
Points : 6370
Réputation : 8
Date d'inscription : 25/04/2009
Age : 35
Localisation : ErRabat

https://ci-vinci.forum-actif.net

Revenir en haut Aller en bas

L'authentification via les info d'une BDD MySQL Empty Re: L'authentification via les info d'une BDD MySQL

Message par owenho Sam 19 Sep - 19:42

La méthode get_magic_quotes_gpc() verifie si la protection des guillemets(par des slashes " => /" ) est activée ou non. S'il est activée, on utilise nos variable sans risque, sinon, on les protège avec addslashes() .
d'aaaacooord
la premier %s va se remplacer avec la premier verification de get_magic_quotes_gpc() .et aussi la deusieme ...
n'est ce pas MALIGNO
owenho
owenho
Modérateur
Modérateur

Messages : 115
Points : 5744
Réputation : 4
Date d'inscription : 02/05/2009
Age : 34
Localisation : larache/rabat

Revenir en haut Aller en bas

L'authentification via les info d'une BDD MySQL Empty Re: L'authentification via les info d'une BDD MySQL

Message par Contenu sponsorisé


Contenu sponsorisé


Revenir en haut Aller en bas

Revenir en haut

- Sujets similaires

 
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum