I have written a script of autentification which does not work, although i find it as simple as possible.
this is it:
connexion.php
bd.php
The mistake on the screen is :
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/hotelpen/public_html/administration/connexion.php on line 16
Warning: Cannot modify header information - headers already sent by (output started at /home/hotelpen/public_html/administration/connexion.php:16) in /home/hotelpen/public_html/administration/connexion.php on line 22
The line 16 is : $con = mysql_num_rows($result);
the line 22 : else { header ("Location:../"); }
Please help me to understant why it is not working.
this is it:
connexion.php
| Code: |
|
<?php include_once "bd.php"; $login = $_POST['login']; $pass = $_POST['pass']; $pass = md5($pass); $connexion = new BD(); $connexion->Connexion(); $requete = "SELECT * FROM connexion WHERE login='$login' AND pass='$pass';"; $result = mysql_query($requete); $con = mysql_num_rows($result); if ($con!=0) { header ("Location:login.php"); } else { header ("Location:../"); } ?> |
bd.php
| Code: |
|
<?php class BD { var $Serveur; var $Utilisateur; var $MotDePasse; var $BaseDeDonnees; var $connexion; function BD() { $this->Serveur = "localhost"; $this->Utilisateur = "patient"; $this->MotDePasse = "012546"; $this->BaseDeDonnees = "pph"; } function Connexion() { $this->connexion = mysql_connect("$this->Serveur", "$this->Utilisateur", "$this->MotDePasse") or die ("Impossible de se connecter"); $this->SelectionneBD(); } function Deconnexion() { $deconnexion = mysql_close($this->connexion); } function SelectionneBD () { $selection = mysql_select_db($this->BaseDeDonnees); }} ?> |
The mistake on the screen is :
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/hotelpen/public_html/administration/connexion.php on line 16
Warning: Cannot modify header information - headers already sent by (output started at /home/hotelpen/public_html/administration/connexion.php:16) in /home/hotelpen/public_html/administration/connexion.php on line 22
The line 16 is : $con = mysql_num_rows($result);
the line 22 : else { header ("Location:../"); }
Please help me to understant why it is not working.
