voici mon code pour ajouter un membre(ajouter.html): <html> <head> <title>Document sans nom</title> <link rel="stylesheet" type="text/css" href="feuille.css" > <script language="javascript"> function verif() { if(document.formulaire.nom.value == "") { alert ('Veuillez entrer votre nom et vérifier les autres champs'); document.formulaire.nom.focus(); return false; } if(document.formulaire.login.value == "") { alert ('Veuillez entrer votre login et vérifier les autres champs'); document.formulaire.login.focus(); return false; } if(document.formulaire.pwd.value == "") { alert ('Veuillez entrer votre mot de passe et vérifier les autres champs'); document.formulaire.pwd.focus(); return false; } else {document.formulaire.submit(); return true;} } </script> </head>
<body> <div class="conteneur">
<table width="815" height="648" border="0" cellpadding="0" cellspacing="0"> <form method="post" action="gestion.php" name="formulaire"> <tr> <td width="130" height="153" background="morceau6.bmp"> </td> <td colspan="5" background="morceau51.bmp"> </td> <td width="151" background="morceau4.bmp"> </td> </tr> <tr class="nav"> <td rowspan="13" background="morceau7.bmp"> </td> <td width="107" height="26" class="tp"><a href="acceuil.html">Acceuil</a> </td> <td width="106" class="tp"><a href="postulant.html">Liste des postulants</a> </td> <td width="107" class="tp"><a href="etudiant.html">Liste des étudiant </a></td> <td width="107" class="tz"><a href="ajouter.html">Ajouter un membre</a> </td> <td width="107" class="tp"><a href="modifier.html">Modifier votre profil </a></td> <td rowspan="13" background="morceau3.bmp"> </td> </tr>
<tr> <td width="212" height="32" class="to" colspan="2">Nom</td> <td class="reponse" colspan="3"><input name="nom" type="text" class="reponse"> <span style="COLOR: red">*</span></td> </tr>
<tr> <td height="33" class="to" colspan="2">Prenom</td> <td class="reponse" colspan="3"><input name="prenom" type="text" class="reponse"></td> </tr> <tr> <td height="28" class="to" colspan="2"> </td> <td class="reponse" colspan="3"> </td> </tr>
<tr> <td height="26" class="to" colspan="2">Statut</td> <td class="reponse" colspan="3"><input name="statut" type="text" class="reponse"></td> </tr> <tr> <td height="26" class="to" colspan="2"> </td> <td class="reponse" colspan="3"> </td> </tr>
<tr> <td height="26" class="to" colspan="2">E-mail</td> <td class="reponse" colspan="3"><input name="email" type="text" class="reponse"></td> </tr> <tr> <td height="26" class="to" colspan="2">Téléphone</td> <td class="reponse" colspan="3"><input name="telephone" type="text" class="reponse"></td> </tr> <tr> <td height="26" class="to" colspan="2"> </td> <td class="reponse" colspan="3"> </td> </tr> <tr> <td height="26" class="to" colspan="2">Login</td> <td class="reponse" colspan="3"><input name="login" type="text" class="reponse"> <span style="COLOR: red">*</span></td> </tr> <tr> <td height="26" class="to" colspan="2">Mot de passe </td> <td class="reponse" colspan="3"><input name="pwd" type="password" class="reponse"> <span style="COLOR: red">*</span></td> </tr> <tr> <td height="28" class="to" colspan="2"> </td> <td class="reponse" colspan="3"> </td> </tr> <tr> <td height="74" class="to" colspan="2"> <!-- <a href="ajouter.html" onclick="javascript: return verif();" class="bouton"> <img src="logoff.gif">Suivant</a></button>--> <input type="submit" value="send"> </td> <td class="reponse" colspan="3"><span style="COLOR: red; font-size:9px">* important!</span></td> </tr> <tr> <td height="72" background="morceau8.bmp"> </td> <td colspan="5" background="morceau1.bmp"> </td> <td background="morceau2.bmp" width="151"> </td> </tr> </form> </table> </div> </body> </html> son fichier de traitement(gestion.php): <?php $nom=$_POST['nom']; $prenom=$_POST['prenom']; $statut=$_POST['statut']; $email=$_POST['email']; $telephone=$_POST['telephone']; $login=$_POST['login']; $pwd=$_POST['pwd'];
//Sauvegarde des données dans la Base $connexion=mysql_connect('localhost','root','') or die ('Erreur de connexion à la BD'); mysql_select_db('aca_cisco') or die ('Sélection BD impossible'); $requete1=mysql_query ("grant select, insert, update, delete on aca_cisco.* to '$login'@'localhost' identified by '$pwd' with grant option") OR die (mysql_error()); $requete2=mysql_query("insert into membres (nom_mbre,prenom_mbre,statut_mbre,tel_mbre,email_mbre,login_mbre,mp_mbre) values ('$nom','$prenom','$statut','$telephone','$email','$login','$pwd')") or die (mysql_error()); mysql_close(); ?> le fichier pour se logger(login.php): <html> <head> <title>Document sans nom</title> <link rel="stylesheet" type="text/css" href="feuille.css" > <script language="javascript"> function verif() { if(document.formulaire.login.value == "") { alert ('Veuillez entrer votre login et vérifier les autres champs'); document.formulaire.login.focus(); return false; } if(document.formulaire.pwd.value == "") { alert ('Veuillez entrer votre mot de passe et vérifier les autres champs'); document.formulaire.pwd.focus(); return false; } else { document.formulaire.submit(); return true;} } </script> </head>
<body> <div class="conteneur">
<table width="815" height="732" border="0" cellpadding="0" cellspacing="0">
<tr> <td width="130" height="156" background="morceau6.bmp"> </td> <td colspan="2" background="morceau5.bmp"> </td> <td width="151" background="morceau4.bmp"> </td> </tr> <tr> <td rowspan="5" background="morceau7.bmp"> </td> <td width="212" height="26"> </td> <td width="322"> </td> <td rowspan="5" background="morceau3.bmp"> </td> </tr> <tr> <td height="32" colspan="2"><span style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; color:#FF0000 "> <?php if(!empty($errorlog)) {echo htmlspecialchars($errorlog);} ?></span> </td> </tr> <tr> <td height="398" colspan="2" background="J0143743.GIF"> <form method="post" action="authentification.php" style="padding:0px 0px 25px 0px"> <div class="Login"> <fieldset> <legend>Authentification </legend> <p> </p> <label class="tb">login :</label> <input name="login" class="tb"> <br><br> <label class="tb" >Mot de passe :</label> <input name="pwd" type="password" class="tb"> <p> </p> <div > <button class="btn"><img src="logoff.gif">Connexion</button> </div> </fieldset> </div> </form> </td> </tr> <tr> <td height="28"> </td> <td> </td> </tr> <tr> <td height="20"></td></td> <td> </td> </tr> <tr> <td height="72" background="morceau8.bmp"> </td> <td colspan="2" background="morceau1.bmp"> </td> <td background="morceau2.bmp" width="151"> </td> </tr> </table> </div> </body> </html> son fichier de traitement(authentification.php): <?php $login=$_POST['login']; $pwd=$_POST['pwd'];
$connexion=mysql_connect('localhost',"$login","$pwd") OR die ('Erreur de connexion'); mysql_select_db('aca_cisco') Or die ('Erreur de sélection de la base'); $requete=mysql_query("select prenom_mbre from membres where login_mbre='$login' and mp_mbre='$pwd'") OR die (mysql_error()); mysql_close();
$resultat=mysql_fetch_object($requete); $resultat=$resultat->prenom_mbre; if (empty($resultat)){ $errorlog = 'Login ou mot de passe incorrect'; } $fichier=fopen('acceuil1.html','rb'); $script=fread($fichier, filesize('acceuil1.html')); fclose($fichier);
$script= ereg_replace('\[NOM\]',$resultat,$script);
$new=fopen('acceuil.html','w'); fputs($new,$script); fclose($new); if($login=="admin") {header('Location: acceuil.html'); exit();} else{header('Location: acceuil.html'); exit();} ?>
et une page ki doi se logger directement mè je cè pa prkoi cè pa le k pourtant le mot de passe et le login sont dans la bd(postulant.php): <html> <head> <title>Document sans nom</title> <link rel="stylesheet" type="text/css" href="feuille.css" > <script language="javascript"> function verif() { if(document.formulaire.nom.value == "") { alert ('Veuillez entrer votre nom et vérifier les autres champs'); document.formulaire.nom.focus(); return false; } if(document.formulaire.login.value == "") { alert ('Veuillez entrer votre login et vérifier les autres champs'); document.formulaire.login.focus(); return false; } if(document.formulaire.pwd.value == "") { alert ('Veuillez entrer votre mot de passe et vérifier les autres champs'); document.formulaire.pwd.focus(); return false; } else {document.formulaire.submit(); return true;} } </script> </head>
<body> <div class="conteneur">
<table width="815" height="648" border="0" cellpadding="0" cellspacing="0"> <form method="post" action="gestion.php" name="formulaire"> <tr> <td width="130" height="153" background="morceau6.bmp"> </td> <td colspan="5" background="morceau51.bmp"> </td> <td width="151" background="morceau4.bmp"> </td> </tr> <tr class="nav"> <td rowspan="2" background="morceau7.bmp"> </td> <td width="107" height="26" class="tp"><a href="acceuil.html">Acceuil</a></td> <td width="106" class="tz"><a href="postulant.html">Liste des postulants</a></td> <td width="107" class="tp"><a href="etudiant.html">Liste des étudiant</a></td> <td width="107" class="tp"><a href="ajouter.html">Ajouter un membre</a></td> <td width="107" class="tp"><a href="modifier.html">Modifier votre profil</a></td> <td rowspan="2" background="morceau3.bmp"> </td> </tr> <tr> <td colspan="5" > <?php // on défini le nombre de colonne sur lesquelles vont s'afficher nos miniatures $nbcol=3; // on compte le nombre de miniatures $login='sofi'; $pwd='sofi'; $connexion=mysql_connect('localhost',"$login","$pwd") or die ('Erreur de connexion à la BD'); mysql_select_db('aca_cisco') or die ('Sélection BD impossible'); $nbre_pos=mysql_query("select max(num_pos) from postulant"); for($i=0;$i < $nbre_pos ;$i++){ $requete[$i]=mysql_query("select * from postulant where num_pos='$i'") or die(mysql_error()); mysql_close(); } for($i=0;$i < $nbre_pos ;$i++){ $resultat[$i]=mysql_fetch_object($requete[$i]); } for($i=0;$i < $nbre_pos ;$i++){ if(!empty($resultat[$i])){ echo $resultat[$i]->num_pos.'-'; echo $resultat[$i]->nom_pos.'<br>'; echo $resultat[$i]->prenom_pos.'<br>'; echo $resultat[$i]->civ_pos.'<br>'; echo $resultat[$i]->date_naiss.' à '; echo $resultat[$i]->lieu_naiss.'<br>'; echo $resultat[$i]->email_pos.'<br>'; echo $resultat[$i]->adr_pos.'<br>'; echo $resultat[$i]->tel_pos.'<br>'; echo $resultat[$i]->fax_pos.'<br>'; echo $resultat[$i]->comment.'<br>'; echo $resultat[$i]->pays.'<br>'; } } ?> </td> </tr> <tr> <td height="72" background="morceau8.bmp"> </td> <td colspan="5" background="morceau1.bmp"> </td> <td background="morceau2.bmp" width="151"> </td> </tr> </form> </table> </div> </body> </html> l'erreur est où
|