Merci
J'avais pensé à qque chose comme cela avant de voir ton exemple (voir code ci-joint)
Le problème c'est que cela ne marche pas dans mon test car je n'arrive pas à inscrire la valeur de OK.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Livre d'Or</title>
<!--Indique une feuille de style interne -->
<style type="text/css">
<!--Couleur des Liens -->
a:link{color:red};
a:visited{color:blue};
a:hover{color:black};
a:active{color:green};
body{
background-color:"#B2B2B2";
text-align:center
}
table{
background-color: "#B2B2B2";
}
<!--Indique la position dans une cellule du tableau -->
td.gauche{text-align:left}
td.droite{text-align:right}
td.centre{text-align:center}
.red{color:red}
</style>
</head>
<SCRIPT Language="JavaScript">
Code : Tout sélectionner
function Controle(test)
{
$OK=true
if(document.test.txtName.value=='')
{
alert('Veuillez renseigner la zone Nom ');
document.test.txtName.focus();
$OK= false;
}
}
</script>
<body>
<!-- Barre de Navigation -->
<table style="padding: 0px; width: 90%; margin-left: auto; margin-right: auto; ;"
border="0" cellpadding="2" cellspacing="2">
<tr>
<td
style="width: auto; text-align: center; color: rgb(102, 0, 0);"><a
href="index.php" style="text-decoration: none;font-size: 20px;">Accueil</a></td>
<td
style="width: auto; text-align: center; color: rgb(102, 0, 0);"><a
href="Themes.php" style="text-decoration: none;font-size: 20px;">Galerie</a></td>
<td
style="width: auto; text-align: center; color: rgb(102, 0, 0);"><a
href="Auteur.php" style="text-decoration: none;font-size: 20px;">Auteur</a></td>
<td
style="width: auto; text-align: center; color: rgb(102, 0, 0);font-size : 20px;">Livre d'Or</td>
<td
style="width: auto; text-align: center; color: rgb(102, 0, 0);font-size: 20px;"><a
href="liens.php" style="text-decoration: none;">Liens</a></td>
</tr>
</table>
<!-- -->
<h1>Bienvenue sur mon livre d'or</h1>
<p> </p>
<?php
include ("connection.php");
//Initialisation des variables
$table="tbllivredor";
//Le message sera reçu par l'intermédiaire du serveur de l'hébergeur (ex Apache)
$page = $_SERVER ["PHP_SELF"];
$adresseemail="
[email protected]";
$name="";
$city="";
$country="";
$email="";
$url="";
$note="";
$comment="";
$result = mysql_query("SELECT * FROM $table ORDER BY id_message DESC");
$total=mysql_numrows($result);
?>
<!-- -->
<table border="1" width="50%" cellspacing="0" cellpadding="5">
<tr>
<td class="gauche">[<a href="#form">Signer le Livre d'Or <SPAN Class="Red">en cliquant ici</SPAN></a>]</td>
<td class="droite">[<b>Au total : <? echo $total; ?> messages</b>]
</tr>
</table>
<!-- -->
<?php
while ($val = mysql_fetch_array($result))
{
?>
<p> </p>
<table border="0" width="50%" cellspacing="0">
<tr>
<td colspan="2" class="gauche"><b>De : </b>
<?= $val["nom"]; ?>
<?php
if ($val["email"]) { ?> <A href="mailto:<?= $val["email"]; ?>"><small>[Écrivez moi] </small></A><?php } ?>
<?php
if ($val["site"]!="http://") { ?><A href="<?= $val["site"]; ?>"><small>[Site Web] </small></A><?php } ?>
</td>
</tr>
<tr>
<td class="gauche">
<?php
if($val["ville"]){echo "<b>Ville : </b>".$val['ville']." "; } ?></td>
<td class="droite"><?php if($val["pays"]){echo "<b>Pays : </b>".$val['pays']."<br>"; } ?></td>
</tr>
<tr>
<td colspan="2"><b>Inscrit le : </b> <?= $val["date"]; ?></td>
</tr>
<tr>
<td colspan="2"><hr><b>Message : </b>
<?= str_replace("<","<",$val["commentaire"]); ?></td>
</tr>
</table>
<?php
}
?>
<!-- -->
<p><a name="form"></a> </p>
<!--Création du formulaire-->
<form method="post" action="<?= $page ?>" name="test">
<fieldset><legend>Laissez nous votre commentaire</legend>
<div style="text-align:center">
<table cellpadding="3">
<tr>
<td colspan="4">Nom <input name="txtName" value="" size="15" maxlength="30"></td>
<td colspan="4">Ville <input name="txtCity" size="15" maxlength="30"></td>
<td colspan="4">Pays <select name="lstCountry">
<option value="France" selected>France
<option value="Grande Bretagne">Grande Bretagne
<option value="Canada">Canada
<option value="Italie">Italie
<option value="Belgique" >Belgique
<option value="Suisse">Suisse
<option value="Luxembourg">Luxembourg
<option value="USA">USA
<option value="Autre">Autre
</select>
</td>
</tr>
<tr>
<td> </td>
<td colspan="5">E-mail<br><input name="txtEmail" size="20" maxlength="30"></td>
<td colspan="5">Site<br><input name="txtUrl" value="http://" size="20" maxlength="30">
</td>
<td> </td>
</tr>
<tr>
<td colspan="12"><br><textarea name="txaComment" rows="10" cols="55"></textarea>
Code : Tout sélectionner
<br><br><input type="button" value="Signer le livre" name="bntSoumet" onClick="javascript:Controle(test);"><input type="reset" value="Effacer"><br>
</td>
</tr>
</table>
</div>
</fieldset>
</form>
<!-- -->
<?php
echo "$OK";
?>
</BODY>
</HTML>