Recherche de personne -Warning: mysql_result()
Résolu
Pritax
Messages postés
333
Date d'inscription
Statut
Membre
Dernière intervention
-
Pritax Messages postés 333 Date d'inscription Statut Membre Dernière intervention -
Pritax Messages postés 333 Date d'inscription Statut Membre Dernière intervention -
bonjour, je cherche à faire une page ou on peut rechercher une personne dans une base et s'y inscrire si non présent ou modifier mes infos sinon.
voila mes code :
PHP :
ma fonction :
<?php
include("connexion-base.php");
$search = $_POST['search'];
if ( (isset($search) && !empty($search))){
$resultat ="SELECT nom,prenom,email,promo,photo FROM compte where nom='$search'";
$resultat_r = mysql_query($resultat) or die('Erreur'.$resultat.'<br />'.mysql_error());
$nom = mysql_result($resultat, 0, 'nom');
$prenom = mysql_result($resultat, 0, 'prenom');
$mail = mysql_result($resultat, 0, 'email');
$promo = mysql_result($resultat, 0, 'promo');
$photo = mysql_result($resultat, 0, 'photo');
echo "<table cellspacing=10 style='border : 1px red inset;'>
<tr><td><img src='$photo' /> </td><tr>
<tr><td>nom : </td><td>$nom</td></tr>
<tr><td>prenom : </td><td>$prenom</td></tr>
<tr><td>mail : </td><td>$mail</td></tr>
<tr><td>Promotion : </td><td>$promo</td></tr>
<br/>
<tr><td><a href='../index.php' style='text-decoration : none; color : gray;'> <- Retour </a></td></tr>
</table>";
}
else{echo "
Nom incorrect ou nom présent dans la base ! </br></br></br>
<a href='../index.php' style='text-decoration : none; color : gray;'> <- Retour </a>
";}
?>
voila mes code :
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" /> <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" /> <link href='http://fonts.googleapis.com/css?family=Abel' rel='stylesheet' type='text/css'> <title>test</title> </head> <body> <!-- ##################### Site - Main #######################--> <div id="site"> <!-- ##################### Body ######################--> <form method="post" action="inc/search.php" class="form-register"> <table> <tr> <td class="inf_form"for="search"> Entrer votre nom :</td> <td class="inf_form2"><input type="text" name="search" id="search" /></td> <td><span class="regbutton"><input type="submit" value="Envoyer " /></span></td> <?php if(isset($_GET['sr']) && ($_GET['sr'] == "vide")){ echo"<div style='color:red'>Vous avez oublie de remplir une saisie</br></br></div>"; }else if(isset($_GET['sr']) && ($_GET['sr'] == "existant")){ echo"<div style='color:red'>Le pseudo saisie est deja existant, merci d'en choisir un autre</br></br></div>"; }else if(isset($_Get['sr']) && ($_GET['sr'] == "erreur")){ echo"nom saisie non valide </br></br>"; }else if(isset($_GET['sr']) && ($_GET['sr'] == "ok")){ echo"<div style='color:green'>Votre compte a bien ete cree</br></br></div>"; } ?> </tr> </table> </form> <div id="container"> <div class="head"> </div> <div class="body"> <div class="register"> Creation de compte</br></br> <?php if(isset($_GET['creation']) && ($_GET['creation'] == "vide")){ echo"<div style='color:red'>Vous avez oublie de remplir une saisie</br></br></div>"; }else if(isset($_GET['creation']) && ($_GET['creation'] == "existant")){ echo"<div style='color:red'>Le pseudo saisie est deja existant, merci d'en choisir un autre</br></br></div>"; }else if(isset($_Get['creation']) && ($_GET['creation'] == "erreur")){ echo"Probleme d'écriture dans la base de donnée</br></br>"; }else if(isset($_GET['creation']) && ($_GET['creation'] == "ok")){ echo"<div style='color:green'>Votre compte a bien ete cree</br></br></div>"; } ?> <form method="post" action="inc/traitement.php" class="form-register"> <table class="infos2" cellpadding=10> <tr> <td class="inf_form"for="nom"> Votre Nom :</td> <td class="inf_form2"><input type="text" name="nom" id="nom" /></td> </tr> <tr> <td class="inf_form"for="prenom"> Votre Prenom :</td> <td class="inf_form2"> <input type="text" name="prenom" id="prenom"></td> </tr> <tr> <td class="inf_form"for="email">Adresse mail:</td> <td class="inf_form2"> <input type="text" name="email" id="email" /></td> </tr> <tr> <td class="inf_form" for="naissance"> Date de Naissance :</td> <td class="inf_form2"> <input type="date" name="naissance" id="naissance" value="1994-04-25" /></td> </tr> <tr> <td class="inf_form" for="tel"> Telephone :</td> <td class="inf_form2"> <input type="text" name="tel" id="tel" /></td> </tr> <tr> <td class="inf_form" for="promo"> A quel promo</br> apparteniez vous ? :</td> <td class="inf_form2"> <select name="promo" id="promo"> <option> 2000/2001</option> <option> 2001/2002</option> <option> 2002/2003</option> <option> 2003/2004</option> <option> 2004/2005</option> <option> 2005/2006</option> <option> 2006/2007</option> <option> 2007/2008</option> <option> 2008/2009</option> <option> 2009/2010</option> <option> 2010/2011</option> <option> 2011/2012</option> </select> </td> </tr> <tr> <td class="inf_form" for="poursuite"> Qu'avez vous fait </br> apres votre DUT ? :</td> <td class="inf_form2"> <input type="text" name="poursuite" id="poursuite" /></td> </tr> <tr> <td class="inf_form" for="metier"> Votre metier actuel :</td> <td class="inf_form2"> <input type="text" name="metier" id="metier" /></td> </tr> <tr> <td> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /></td> <td> Ma photo <input type="file" name="maphoto" /></td> </tr> </table> </br> <span class="regbutton"><input type="submit" value="Envoyer " /></span> </p> </form> </div> </div> </div> </div> <div class="footer"> <br/> <br/> </div> </body> </html>
ma fonction :
<?php
include("connexion-base.php");
$search = $_POST['search'];
if ( (isset($search) && !empty($search))){
$resultat ="SELECT nom,prenom,email,promo,photo FROM compte where nom='$search'";
$resultat_r = mysql_query($resultat) or die('Erreur'.$resultat.'<br />'.mysql_error());
$nom = mysql_result($resultat, 0, 'nom');
$prenom = mysql_result($resultat, 0, 'prenom');
$mail = mysql_result($resultat, 0, 'email');
$promo = mysql_result($resultat, 0, 'promo');
$photo = mysql_result($resultat, 0, 'photo');
echo "<table cellspacing=10 style='border : 1px red inset;'>
<tr><td><img src='$photo' /> </td><tr>
<tr><td>nom : </td><td>$nom</td></tr>
<tr><td>prenom : </td><td>$prenom</td></tr>
<tr><td>mail : </td><td>$mail</td></tr>
<tr><td>Promotion : </td><td>$promo</td></tr>
<br/>
<tr><td><a href='../index.php' style='text-decoration : none; color : gray;'> <- Retour </a></td></tr>
</table>";
}
else{echo "
Nom incorrect ou nom présent dans la base ! </br></br></br>
<a href='../index.php' style='text-decoration : none; color : gray;'> <- Retour </a>
";}
?>
A voir également:
- Recherche de personne -Warning: mysql_result()
- Recherche automatique des chaînes ne fonctionne pas - Guide
- Rechercher ou entrer l'adresse mm - recherche google - Guide
- Recherche photo - Guide
- Je recherche une chanson - Guide
- Fréquence tnt recherche manuelle - Forum TNT / Satellite / Réception
5 réponses
ma fonction : Je suppose que c'est la page search.php ? <?php if ( !empty ($_POST['search'])){ include("connexion-base.php"); //on fait la connexion base seulement qd on en a besoin $search =mysql_real_escape_string($_POST['search']); //securité $requette ="SELECT nom,prenom,email,promo,photo FROM compte where nom='$search'"; $resultat_r = mysql_query($requette) or die('Erreur'.$requette.'<br />'.mysql_error()); //test si nom trouvé dans la base: if(mysql_num_rows()>0){ //ci dessous mysql_result est obsolete à paritr de PHP5 et va être suprimé //de plus tu applique cette fonction sur $resultat qui est la requette et pas le résultat de la requette //d'ou l'interêt de mettre des noms de variables parlants /* $nom = mysql_result($resultat, 0, 'nom'); $prenom = mysql_result($resultat, 0, 'prenom'); $mail = mysql_result($resultat, 0, 'email'); $promo = mysql_result($resultat, 0, 'promo'); $photo = mysql_result($resultat, 0, 'photo'); */ //on fait un fetch du resultat => dans un array $client $client=mysql_fetch_assoc($resultat_r); $nom = $client'nom'); $prenom = $client['prenom']; $mail = $client['email']; $promo = $client['promo']; $photo = $client['photo']; echo "<table cellspacing=10 style='border : 1px red inset;'> <tr><td><img src='$photo' /> </td><tr> <tr><td>nom : </td><td>$nom</td></tr> <tr><td>prenom : </td><td>$prenom</td></tr> <tr><td>mail : </td><td>$mail</td></tr> <tr><td>Promotion : </td><td>$promo</td></tr> <br/> <tr><td><a href='../index.php' style='text-decoration : none; color : gray;'> <- Retour </a></td></tr> </table>"; } else{ echo "Ce nom n'est présent dans la base ! </br></br></br> <a href='../index.php' style='text-decoration : none; color : gray;'> <- Retour </a>"; } } ?>
euh, j'ai un pb,
Parse error: syntax error, unexpected ''nom'' (T_CONSTANT_ENCAPSED_STRING) in ...\EasyPHP-12.1\www\...\inc\search2.php on line 15
Parse error: syntax error, unexpected ''nom'' (T_CONSTANT_ENCAPSED_STRING) in ...\EasyPHP-12.1\www\...\inc\search2.php on line 15
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question