Faute PHP
Romain
-
Gabess Messages postés 1475 Statut Membre -
Gabess Messages postés 1475 Statut Membre -
Bonjour,
Voila le prof nous a donné un code en PHP et il y a des faute dedans, si quelqu'un pourrais m'aider.Merci
<?php
session_start();
//AJOUTER
if($_POST["envoi"]=="AJOUTER" && $_POST["nom"]!="" && $_POST["prenom"]!="" && $_POST["age"]!="")
{
echo gettype($_SESSION['nom']);
$nom=$_POST["nom"];
$prenom=$_POST["prenom"];
$age=$_POST["age"];
$_SESSION['nom'][]=$nom;
$_SESSION["prenom"][]=$prenom;
$_SESSION["age"][]=$age;
print-r($_SESSION['nom']);
}
//VERIFIER
if($_POST["envoi"]=="VERIFIER")
{
echo"<table border=\"1\">";
echo"<tr><th> nom </th><th> prénom </th><th> age </th>";
for($i=0;$i<count($_SESSION["nom"]);$i++)
{
echo"<tr><td>{$_SESSION["nom"][$i]}</td><td>{$_SESSION["prenom"][$i]}
</td><td>{$_SESSION["age"][$i]}</td>";
}
echo"</table>";
}
//ENREGISTRER
if($_POST["envoi"]=="ENREGISTRER")
{
$idfile=fopen("nom.txt",w);
echo gettype($idfile);
echo SID,$PHPSESSID;
for($i=0;$i<count($_SESSION["nom"]);$i++)
{
fwrite($idfile,$_SESSION["nom"][$i].";".$_SESSION["prenom"][$i].";".$_SESSION["age"][$i]."; \n");
}
fclose($idfile);
}
$_POST["envoi"]=="";
?>
<!DOCTYPE HTML PUBLIC "-//W3//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strct.td">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" enctype="application/x-www-form-urlencoded">
<fieldset>
<legend><b>Saisies de noms</b></legend>
<table>
<tbody>
<tr>
<th>nom : </th>
<td> <input type="text" name="nom"/></td>
</tr>
<tr>
<th>prénom : </th>
<td><input type"text"name="prenom"/></td>
</tr>
<tr>
<th>age : </th>
<td><input type"text"name="age"/></td>
</tr>
<tr>
<td colspan="3">
<input type="submit" name="envoi" value="AJOUTER"/>
<input type="submit" name="envoi" value="VERIFIER"/>
<input type="submit" name="envoi" value="ENREGISTRER"/>
</td>
</tr>
</tbody>
</table>
</fieldset>
</form>
</body>
</html>
Voila le prof nous a donné un code en PHP et il y a des faute dedans, si quelqu'un pourrais m'aider.Merci
<?php
session_start();
//AJOUTER
if($_POST["envoi"]=="AJOUTER" && $_POST["nom"]!="" && $_POST["prenom"]!="" && $_POST["age"]!="")
{
echo gettype($_SESSION['nom']);
$nom=$_POST["nom"];
$prenom=$_POST["prenom"];
$age=$_POST["age"];
$_SESSION['nom'][]=$nom;
$_SESSION["prenom"][]=$prenom;
$_SESSION["age"][]=$age;
print-r($_SESSION['nom']);
}
//VERIFIER
if($_POST["envoi"]=="VERIFIER")
{
echo"<table border=\"1\">";
echo"<tr><th> nom </th><th> prénom </th><th> age </th>";
for($i=0;$i<count($_SESSION["nom"]);$i++)
{
echo"<tr><td>{$_SESSION["nom"][$i]}</td><td>{$_SESSION["prenom"][$i]}
</td><td>{$_SESSION["age"][$i]}</td>";
}
echo"</table>";
}
//ENREGISTRER
if($_POST["envoi"]=="ENREGISTRER")
{
$idfile=fopen("nom.txt",w);
echo gettype($idfile);
echo SID,$PHPSESSID;
for($i=0;$i<count($_SESSION["nom"]);$i++)
{
fwrite($idfile,$_SESSION["nom"][$i].";".$_SESSION["prenom"][$i].";".$_SESSION["age"][$i]."; \n");
}
fclose($idfile);
}
$_POST["envoi"]=="";
?>
<!DOCTYPE HTML PUBLIC "-//W3//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strct.td">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" enctype="application/x-www-form-urlencoded">
<fieldset>
<legend><b>Saisies de noms</b></legend>
<table>
<tbody>
<tr>
<th>nom : </th>
<td> <input type="text" name="nom"/></td>
</tr>
<tr>
<th>prénom : </th>
<td><input type"text"name="prenom"/></td>
</tr>
<tr>
<th>age : </th>
<td><input type"text"name="age"/></td>
</tr>
<tr>
<td colspan="3">
<input type="submit" name="envoi" value="AJOUTER"/>
<input type="submit" name="envoi" value="VERIFIER"/>
<input type="submit" name="envoi" value="ENREGISTRER"/>
</td>
</tr>
</tbody>
</table>
</fieldset>
</form>
</body>
</html>
A voir également:
- Faute PHP
- Easy php - Télécharger - Divers Web & Internet
- Expert php pinterest - Télécharger - Langages
- Correcteur de faute - Guide
- Retour a la ligne php - Forum Webmastering
- Comment corriger une faute sur whatsapp - Guide