vérification champs formulaire
Bonjour,
J'ai réaliser un formulaire pour l'ajout d'un nouveau contrat et voici la formulaire
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| <form name="contrat" method="post" action="">
<table width="440" border="0">
<tr>
<td width="125">Nom entreprise </td>
<td width="299"><input name="nome" type="text" style="font-family:Courier New;font-size:12px"/></td>
</tr>
<tr>
<td>Référence kiosque </td>
<td><input name="refk" type="text" style="font-family:Courier New;font-size:12px" /></td>
</tr>
<tr>
<td>Date début location</td>
<td><input type="text" id="nom_champs_date" style="font-family:Courier New;font-size:12px" name="nom_champs_date" value=""><a href="javascript:popupwnd('calendrier.php?idcible=nom_champs_date&langue=fr','no','no','no','yes','yes','no','50','50','450','280')" target="_self"><img src="calendrier.gif" id="Image1" alt="" align="top" border="0" style="width:26px;height:26px;"></a></td>
</tr>
<tr>
<td>Date fin location</td>
<td><input type="text" id="nom_champs_date2" style="font-family:Courier New;font-size:12px" name="nom_champs_date" value=""><a href="javascript:popupwnd('calendrier.php?idcible=nom_champs_date2&langue=fr','no','no','no','yes','yes','no','50','50','450','280')" target="_self"><img src="calendrier.gif" id="Image1" alt="" align="top" border="0" style="width:26px;height:26px;"></a></td>
</tr>
<tr>
<td>Prix</td>
<td><input name="prix" type="text" style="font-family:Courier New;font-size:12px"/></td>
</tr>
<tr>
<td><input name="verifier" type="submit" value="vérifier"/></td>
<td> </td>
</tr>
</table>
</form> |
lorsque je clique sur verifier le code php suivant s'exécute
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| <?php
if (isset($_POST['verifier']))
{
include ("connexion.php");
$nom=$_POST['nome'];
$req= "select nom_sct from entreprise where nom_sct= $nom ";
$res= mysql_query($req) ;
if (!$res) {
echo "Could not successfully run query ($req) from DB: " . mysql_error();
}
if (mysql_num_rows($res) == 0) {
echo "No rows found, nothing to print so am exiting";}
}
?> |
L'exécution marche mais avec l'affichage de certains erreur, voilà ce que sera affiché lorsque le nom de l'entreprise n'existe pas
Could not successfully run query (select nom_sct from entreprise where nom_sct= ) from DB: Erreur de syntaxe pr�s de '' � la ligne 1
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in D:\Program Files\EasyPHP-5.3.1\www\hbs\contrat.php on line 11
No rows found, nothing to print so am exiting
Merci de m'aider à résoudre ce problème .