Les scripts PHP peuvent être insérés à n'importe quel endroit d'une page HTML.
Exemple [voir]<html>
<body>
<form method="post" action="formulaire.php">
<table border="0">
<tr>
<td>Nom</td>
<td><input type="text" name="nom" size="20"></td>
</tr>
<tr>
<td>Adresse</td>
<td><textarea name="adresse" cols="20" rows="3"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="soumettre" value="Envoyer"></td>
</tr>
</table>
</form>
</body>
</html>
<!-- Fichier de traîtement : formulaire.php -->
<html>
<body>
<?php
if($nom)
{
if($adresse)
{
?>
<table border="0">
<tr>
<td>Nom</td>
<td><?php echo $nom ?></td>
</tr>
<tr>
<td>Adresse</td>
<td><?php echo $adresse ?></td>
</tr>
</table>
<?php
}
else
{
echo "<h1>Le champ Adresse n'a pas été rempli !</h1>";
}
}
else
{
echo "<h1>Le champ Nom n'a pas été rempli !</h1>";
}
?>
</body>
</html> |