Condition pour une requete selection

Bonjour,
tt le mondes jaimerai savoir comment inserer une condition de verification ,je mexplique jai creer une base"personne" et jai creer aussi une autre page appelee "requeteselection.php" dou elle fait appel a la base pour savoir si le visiteur est membre ou pas voici les trois pages (connexion,requeteselection,home)

code
home.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>bonjour</title>

<script language="alerte" type="text/javascript">
function verif(){
if ((document.form1.textfield.value =="")||(document.form1.textfield2.value =="")){
alert ("Il faut remplir tous les champs.");
return false;}
else
{return true;}
}
</script>

<!--<link rel="stylesheet" type="text/css" href="style.css" />--!>

<style type="text/css">
<!--
.Style1 {color: #FFFFFF}
.Style2 {
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
font-style: italic;
}
.Style3 {
font-family: Geneva, Arial, Helvetica, sans-serif, "Adobe Garamond Pro", "Adobe Caslon Pro Bold", "Adobe Caslon Pro"
}
.Style6 {color: #999999; }
-->
</style>
<style type="text/css">
<!--
.Style1 {font-family: Georgia, "Times New Roman", Times, serif}
.Style2 {color: #FFFFFF}
.Style3 {
font-family: Geneva, Arial, Helvetica, sans-serif, "Adobe Garamond Pro", "Adobe Caslon Pro Bold", "Adobe Caslon Pro";
font-weight: bold;
font-style: italic;
font-size: 14px;
}
a:link {
color: #FFFFFF;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #FFFFFF;
}
a:hover {
text-decoration: underline;
color: #FFFFFF;
}
a:active {
text-decoration: none;
color: #FFFFFF;
}
.Style10 {
font-size: 14px;
color: #FFFFFF;
font-family: Geneva, Arial, Helvetica, sans-serif, "Adobe Garamond Pro", "Adobe Caslon Pro Bold", "Adobe Caslon Pro";
font-weight: bold;
font-style: italic;
}
.Style11 {color: #FFFFFF; font-weight: bold; }
.Style9 { color: #FFFFFF;
font-size: 10px;
font-style: italic;
}
.Style8 {font-style: italic; color: #FFFFFF; font-size: 18px;}
.Style12 {
font-style: italic;
color: #FFFFFF;
font-size: 18px;
font-family: Geneva, Arial, Helvetica, sans-serif, "Adobe Garamond Pro", "Adobe Caslon Pro Bold", "Adobe Caslon Pro";
font-weight: bold;
}
-->
</style>
</head>

<body>
<div align="center">
<table width="1024" height="609" border="1" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2"> </td>
</tr>
<tr background="image.jpg">
<td height="90" colspan="2" nowrap="nowrap"><div align="right"><img src="image.jpg" width="800" height="88" /></div></td>
</tr>
<tr background="1.jpg">
<td height="37" colspan="2" nowrap="nowrap" class="menu"><div align="center" class="Style1">
<div align="center" class="Style2">
<div align="right" class="Style2 Style3">
<a href="home.php">HOME </a>| <a href="presentation.php">PRESENTATION </a>| <a href="operations.php">OPERATION</a> | <a href="contact.php">NOS CONTACTS</a> | <a href="sondage.php">SONDAGE</a> | <a href="lien.php">LIENS UTILES</a></div>
</div>
</div></td>
</tr>
<tr background="2.jpg">
<td width="147" height="478px" rowspan="2" nowrap="nowrap" class="bar"><p align="center" class="Style9">SI VOUS N'ETES PAS </p>
<p align="center" class="Style9">MEMBRE VEUILLEZ VOUS INSCRIRE</p>
<p align="center" class="Style11"><a href="INSCRIPTION.php">ICI</a></p></td>
<td width="871" height="445" nowrap="nowrap" class="contenu">
<form id="form1" name="form1" method="post" action="requeteselection.php" onclick="return verif()">
<p align="center" class="Style12">VEUILLEZ VOUS IDENTIFIER</p>
<p align="center" class="Style8">LOGIN
<input type="text" name="textfield" id="textfield" />
</p>
<p align="center" class="Style8">MOT DE PASSE
<input type="password" name="textfield2" id="textfield2" />
</p>
<p align="center" class="Style8">
<input type="submit" name="VALIDER" id="VALIDER" value="VALIDER" />
</p>
</form>
</td>
</tr>
<tr>
<td height="20" colspan="2" nowrap="nowrap" background="4.jpg" class="footer">
<div align="right"><span class="Style10"><a href="contact.php"> NOS CONTACTS</a> | <a href="sondage.php">SONDAGE</a> | <a href="lien.php">LIENS UTILES</a></span> </div></td>
</tr>
</table>
</div>
</body>
</html>

code requeteselection.php

<?php

include("connexion.php");?>

<?php
$logine=$_POST["textfield"];
$passe=$_POST["textfield2"];

$sql ="SELECT * FROM identification WHERE login='$logine' AND mot de passe ='$passe'";

$req = @mysql_query($sql);
$data = @mysql_fetch_array($req);

if(($logine==login)&&($passe==mot de passe))

echo" vous etes mr ou madame:$logine";

else

echo"vous netes pas membre";
?>

c ce ke jai pu faire pour la conditon jaimerai ke vous maidiez pour la faire con venablement

code connexion.php

<?php
$host="localhost";
$user="root";
$db="personne";
$password="";
mysql_connect($host,$user,$password);
mysql_select_db("$db");
?>
Configuration: Windows XP
Safari 532.0

2 réponses

  • Votes
  • Date
  • Date décroissante
  1. bein c'est dans ton if que ca va pas,

    tu as stocké ta requete ($req) dans un mysql_fetch_array donc en gros le principe c'est

    tu recupere les données des champs :
    $login = mysql_real_escape_string($_POST['login']);
    $mdp = mysql_real_escape_string($_POST['mdp']);

    La fonction mysql_real_escape_string te permet de securiser tes variables.

    Ensuite tu fais ta requête seulement sur le login (enfin c'est ce que je fais generalement) mais tu peut faire autrement bien sur.

    $sql = mysql_query("SELECT * FROM membre WHERE login=$login");

    maintenant on fou ca dans un array :

    $data = mysql_fetch_array($sql)

    Puis on est d'accord si la requete a renvoyé quelquechose c'est qu'une personne ayant ce pseudo existe, on va donc voir si le mot de passe en base de donnée pour ce pseudo est égale a celui entré dans le formulaire :

    if ( $data['champs_mot_de_passe'] == $mdp ) {
    echo "tu es connecté";

    }

    ton souci c'est que tu mettais le nom des champs des tables pour comparé et non le $data['nom_du_champs_de_la_table];

    voila si j'ai pu t'aider !

    bye
    1. ba merci samy jai testé cela avec les modifications mai ca n'a pas marché

      <?php

      include("connexion.php");?>

      <?php

      $logine = mysql_real_escape_string($_POST['textfield']);
      $passe = mysql_real_escape_string($_POST['textfield2']);

      $sql ="SELECT * FROM identification WHERE login='$logine' AND mot de passe='$passe'";

      $req = @mysql_query($sql);
      $data = @mysql_fetch_array($req);

      if ( $data['textfield'] == $passe ) {
      echo "tu es connecté";

      echo"tu es connecté";

      ?>
      aide moi svp ca fait des semaines que chui coincé merci