probleme de connexion à la base
Posté : 29 mars 2012, 14:10
Bonjour,
je débute en php et je suis entr1 de faire mon premier site web
mon probleme c que lorsque qu'un utilisateur veut s'identifier c'est le fichier index.php qui se telecharge c bizar voila mon fichier accueil.html
et mon fichier index.php
<?php
mysql_connect("localhost", "root", "") or die("Impossible de se connecter à la base de
données");
mysql_select_db("inscription") or die("base inexistante");
$login = $_POST["login"];
$mdp = $_POST["pass"];
if ($login != "" && $mdp != "") {
$sql="SELECT * from formulaire_inscri WHERE login='$login' AND pass='$mdp';";
$resultat = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($resultat)<1)
echo "Authentification non réussie.";
else echo "<script>window.location='./admin.php'</script>";
}
else header("Location: ./");
mysql_close();
[/code]
merci d'avance
je débute en php et je suis entr1 de faire mon premier site web
mon probleme c que lorsque qu'un utilisateur veut s'identifier c'est le fichier index.php qui se telecharge c bizar voila mon fichier accueil.html
et mon fichier index.php
Code : Tout sélectionner
<html>
<head>
<div align="center"><h1>TP1 - Page d'authentification</h1></div>
<title>Faille de type SQL Injection</title>
</head>
<body>
<div align="center">
<form action="./index.php" method="POST">
<table>
<tr>
<td>Login</td>
<td><input type="text" name="login" maxlength="100"></td>
</tr>
<tr>
<td>Pass</td>
<td><input type="password" name="pass" maxlength="100"></td>
</tr>
<tr><td colspan=2 align="center"><input type="submit" name="login" value="Login"></td></tr>
</table>
</form>
</div>
</body>
</html>[code]mysql_connect("localhost", "root", "") or die("Impossible de se connecter à la base de
données");
mysql_select_db("inscription") or die("base inexistante");
$login = $_POST["login"];
$mdp = $_POST["pass"];
if ($login != "" && $mdp != "") {
$sql="SELECT * from formulaire_inscri WHERE login='$login' AND pass='$mdp';";
$resultat = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($resultat)<1)
echo "Authentification non réussie.";
else echo "<script>window.location='./admin.php'</script>";
}
else header("Location: ./");
mysql_close();
[/code]
merci d'avance