Code php
anis
-
CrazyWorld Messages postés 326 Date d'inscription Statut Membre Dernière intervention -
CrazyWorld Messages postés 326 Date d'inscription Statut Membre Dernière intervention -
Bonjour, j'ai un code php qui me permet de me lier une page à une autre page(c'est à dire que lorsque je clique sur le bouton OK, il va me ramener à une autre page web qui contient un tableau) mais il ne marche pas
avez vous une idé, je vous donne le boue de code:
<?php
$cnx = mysql_connect("localhost","root","") or die(mysql_error());
$db = mysql_select_db("magasin2");
?>
<?php session_start();?>
<!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>Document sans titre</title>
</head>
<body>
<form id="form" name="forma" action="" method="post">
<table width="300" border="0">
<tr>
<td>Code Client</td>
<td><input name="code_client" type="text" /></td>
<td><input name="ok" type="button" value="OK" /></td>
</tr>
</table>
</form>
<?php
if(isset($_POST['ok']))
{
$code_client = $_POST['code_client'];
if($code_client=='')
{
echo "veuillez renseigner le champ obligatoire vide(code clientl)";
}
else
{$sql = mysql_query("SELECT * FROM clients WHERE code_client = '".$code_client."'" ) or die(mysql_error());
if(mysql_num_rows($sql)!=0)
{$_SESSION['code_client']=$code_client;
session_register($_SESSION['code_client']);
/*ici on va aller à la 2 émmes page */
header("location:consult_articles.php");
}
}
}
?>
</body>
</html>
la faute c'est au niveau de dernière ligne: des balises non fermer mais tous apparemment sont bien fermés
je ne sais pas ou le problème, merci en avance pour vos aide.
avez vous une idé, je vous donne le boue de code:
<?php
$cnx = mysql_connect("localhost","root","") or die(mysql_error());
$db = mysql_select_db("magasin2");
?>
<?php session_start();?>
<!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>Document sans titre</title>
</head>
<body>
<form id="form" name="forma" action="" method="post">
<table width="300" border="0">
<tr>
<td>Code Client</td>
<td><input name="code_client" type="text" /></td>
<td><input name="ok" type="button" value="OK" /></td>
</tr>
</table>
</form>
<?php
if(isset($_POST['ok']))
{
$code_client = $_POST['code_client'];
if($code_client=='')
{
echo "veuillez renseigner le champ obligatoire vide(code clientl)";
}
else
{$sql = mysql_query("SELECT * FROM clients WHERE code_client = '".$code_client."'" ) or die(mysql_error());
if(mysql_num_rows($sql)!=0)
{$_SESSION['code_client']=$code_client;
session_register($_SESSION['code_client']);
/*ici on va aller à la 2 émmes page */
header("location:consult_articles.php");
}
}
}
?>
</body>
</html>
la faute c'est au niveau de dernière ligne: des balises non fermer mais tous apparemment sont bien fermés
je ne sais pas ou le problème, merci en avance pour vos aide.
A voir également:
- Code php
- Code ascii - Guide
- Code puk bloqué - Guide
- Comment déverrouiller un téléphone quand on a oublié le code - Guide
- Code activation windows 10 - Guide
- Scanner qr code pc - Guide
3 réponses
Essaye de voir si la requete retourne bien quelque chose
if(mysql_num_rows($sql)==0)
{
echo "pas de resultat";
}
if(mysql_num_rows($sql)==0)
{
echo "pas de resultat";
}
</body>
</html>
je pense qu'il y a une balise non fermé mais j'ai vérifié le code.
essaye de replacer par
voilà le code qui contient le bug:
<table width="500" align="center">
<tr>
<td>Reference</td>
<td>Categorie</td>
<td>Designation</td>
<td>numfs</td>
<td>prixht</td>
<td>tauxtva</td>
<td>qtstock</td>
<td>qteminstock</td>
<td>Action</td>
</tr>
<tr>
<td colspan="9" ></td>
</tr>
<?php
/* requete pour le selection de tous les données d'un client*/
$sql=mysql_query("select * from articles ") or die(mysql_error());
/* on vérifie si on arrive à la fin de tableau */
while($data=mysql_fetch_array($sql))
{
?>
<tr>
<td ><?php echo $data['ref_art'];?></td>
<td><?php echo $data['categorie'];?></td>
<td><?php echo $data['designation'];?></td>
<td ><?php echo $data['numfs'];?></td>
<td ><?php echo $data['prixht'];?></td>
<td ><?php echo $data['tauxtva'];?></td>
<td ><?php echo $data['qtestock'];?></td>
<td ><?php echo $data['qteminstock'];?></td>
<td><a href="../../../../Windows.old/Program Files/EasyPHP-5.3.5.0/www/projet2/consult_articles.php?Ref=<?php echo $data['ref_art'];?>">SUPP</a></td>
</tr>
<?php }
?>
</table>
</body>
</html>
le bug est dans le drenier ligne après </body>
</html>
je pense que il y a une balise non fermé mais je ne sais pas où!!!???
c'est le ligne qui est après </body>
</html>