Formulaire qui ne s'affiche pas
Posté : 28 nov. 2005, 00:18
Bonsoir,
Dés que je mets une condition de saisie dans mon formulaire, la page apparaît blanche.
Merci de votre aide
Dés que je mets une condition de saisie dans mon formulaire, la page apparaît blanche.
Merci de votre aide
<?php
// Exemple de livre d'or.
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="";
if (isset($_POST["txtName"])) $name=htmlspecialchars(stripslashes($_POST["txtName"]), ENT_QUOTES);
if (isset($_POST["txtCity"])) $city=htmlspecialchars(stripslashes($_POST["txtCity"]), ENT_QUOTES);
if (isset($_POST["lstCountry"])) $country=htmlspecialchars(stripslashes($_POST["lstCountry"]), ENT_QUOTES);
if (isset($_POST["txtEmail"])) $email=htmlspecialchars(stripslashes($_POST["txtEmail"]), ENT_QUOTES);
if (isset($_POST["txtUrl"])) $url=htmlspecialchars(stripslashes($_POST["txtUrl"]), ENT_QUOTES);
if (isset($_POST["txaComment"])) $comment=htmlspecialchars(stripslashes($_POST["txaComment"]), ENT_QUOTES);?>
<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>
<!-- 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>
<?php
// Si le bouton Signer le livre a été enfoncé et que Nom et Commentaire ne sont pas vides
if (empty($comment) && empty($name))
{
echo "Vous devez complétez" ;
}
else {
$date = date("d/m/y");
$email=str_replace("@","@",$email); //cryptage du signe @
$query = "INSERT INTO $table(date,nom,ville,pays,email,site,commentaire)";
$query .= " VALUES('$date','$name','$city','$country','$email','$url','$comment')";
$result = mysql_query($query);
//envoi d'un mail au webmaster
mail($adresseemail,"Nouveau message dans le livre d'OR",$date."\nNom :".$name."\nVille :".$city."\nPays :".$country."\nMail :".$email."\nSite :".$url."\nTexte :".$comment);
}
?>
<!-- -->
<p id="rep">Merci d'avoir signé le livre d'or</p>
<p>
Le message sera rajouté dès que possible
</p>
<p>
<a href="<?= $page ?>">-- Retourner sur le livre d'or --</a>
</p>
<!-- -->
<?php
}
else{
?>
<!-- -->
<h1>Bienvenue sur mon livre d'or</h1>
<p> </p>
<?php
$result = mysql_query("SELECT * FROM $table ORDER BY id_message DESC");
$total=mysql_numrows($result);
$row = mysql_fetch_assoc(mysql_query("SELECT truncate(AVG(note),0) AS rating FROM $table"));
?>
<!-- -->
<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 ?>">
<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>
<br><br><input type="submit" value="Signer le livre" name="bntSoumet"><input type="reset" value="Effacer"><br>
</td>
</tr>
</table>
</div>
</fieldset>
</form>
<!-- -->
<?php
}
?>
</BODY>
</HTML>
<?php mysql_close(); ?>