Codice PHP:
<!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"><!-- InstanceBegin template="/Templates/PG Azzurra 2.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Form Guestbook</title>
<!-- InstanceEndEditable -->
<link href="CSS/PG_Style_3.css" rel="stylesheet" type="text/css" />
<!-- InstanceBeginEditable name="head" -->
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationTextarea.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationTextarea.css" rel="stylesheet" type="text/css" />
<script src="http://js.nicedit.com/nicEdit-latest.js" type="text/javascript"></script>
<script type="text/javascript">bkLib.onDomLoaded(nicEditors.allTextAreas);</script>
<!-- InstanceEndEditable -->
</head>
<body>
<div id="Container">
<div id="Header"><img src="Immagini/Header/Header.png" width="970" height="222" alt="Logo" /></div>
<div id="Left">
<div id="Menu">
<p><a href="#">Voce 1</a></p>
<p><a href="#">Voce 2</a></p>
<p><a href="#">Voce 3</a></p>
<p><a href="#">Voce 4</a></p>
<p><a href="#">Voce 5</a></p>
<p><a href="#">Voce 6</a></p>
<p><a href="#">Voce 7</a></p>
<p><a href="#">Voce 8</a></p>
<p><a href="#">Voce 9</a></p>
<p><a href="#">Voce 10</a></p>
<p><a href="#">Voce 11</a></p>
<p><a href="#">Voce 12</a></p>
<p><a href="#">Voce 5</a></p>
</div>
<div id="News">
<div id="Box">
<h1><!-- InstanceBeginRepeat name="TitoloBox1_Rip" --><!-- InstanceBeginRepeatEntry --><!-- InstanceBeginEditable name="TitoloBox1_Mod" -->Redazione<!-- InstanceEndEditable --><!-- InstanceEndRepeatEntry --><!-- InstanceEndRepeat --></h1>
<!-- InstanceBeginRepeat name="TextBox1_Rip" --><!-- InstanceBeginRepeatEntry --><!-- InstanceBeginEditable name="TextBox1_Mod" -->
<p>Caporedattore:<br />
<strong>xxx<br />
<br />
</strong><em>Rubriche:</em><br />
<br />
</p>
<!-- InstanceEndEditable --><!-- InstanceEndRepeatEntry --><!-- InstanceEndRepeat --></div>
<div id="Box2">
<h1>Seguici su</h1>
<p><a href="https://www.facebook.com/pagina"><img src="Immagini/Images/FB.png" width="40" height="40" alt="Facebook" /></a> <a href="https://www.twitter.com/pagina"><img src="Immagini/Images/Twt.png" width="40" height="40" alt="Twitter" /></a></p>
</div>
<div id="Box3">
<h1> Il Paese</h1>
<img src="IND_img" alt="Panorama (Panorama width="99" height="65"/><br />
<a href="ilpaese.html">Informazioni</a>
</div>
</div>
</div>
<!-- InstanceBeginEditable name="AreaContenuto" -->
<div id="Contenuto">
<h1> </h1>
<div id="form">
<form id="Guestbook" name="form1" method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>">
<fieldset>
<legend>Scrivi nel Guestbook!</legend><hr />
<p><span id="nome">
<label for="name">Nome*:</label>
<input type="text" name="name" id="name" tabindex="10" />
<br />
<span class="textfieldRequiredMsg">È obbligatorio specificare un valore.</span><span class="textfieldInvalidFormatMsg">Formato non valido.</span></span></p>
<p><span id="cognome">
<label for="surname">Cognome:</label>
<input type="text" name="surname" id="surname" tabindex="20" />
<span class="textfieldInvalidFormatMsg">Formato non valido.</span></span></p>
<p><span id="email">
<label for="e_mail">Email*:</label>
<input type="text" name="e_mail" id="e_mail" tabindex="30" />
<br />
<span class="textfieldRequiredMsg"><br />
È obbligatorio specificare un valore.</span><span class="textfieldInvalidFormatMsg"><br />
L'indirizzo specificato non è valido.</span></span></p>
<!-- <input value="G" type="button" style="font-weight: bold;" onclick='bold();'>-->
<p><span id="messaggio">
<label for="message">Messaggio*:</label>
<textarea name="message" id="message" cols="45" rows="5" tabindex="40"></textarea>
<span class="textareaRequiredMsg"><br />
È obbligatorio specificare un valore.</span><span class="textareaMinCharsMsg"><br />
Il tuo messaggio è troppo corto! </span></span></p>
<p>
<input type="submit" name="send" id="send" value="Invia" tabindex="50" />
<input type="reset" name="reset" id="reset" value="Reset" tabindex="60" />
</p>
</fieldset>
</form>
<br />
</div>
<p>
<?php
if (isset($_POST["send"]) && $_POST["send"] == "Invia") {
$tag_permessi="<br> <br /> <b> <strong> <i> <u> <hr>";
$name=addslashes(trim(strip_tags($_POST['name'])));
$surname=addslashes(trim(strip_tags($_POST['surname'])));
$message=addslashes(trim(strip_tags($_POST['message'], $tag_permessi)));
$e_mail=addslashes(trim(strip_tags($_POST['e_mail'])));
$errore_si_no="";
if($name==""){$errore_si_no .="Il nome è obbligatorio<br>";}
if(strlen($message) < 10){$errore_si_no .="Il tuo messaggio è troppo corto<br>";}
if(!filter_var($e_mail, FILTER_VALIDATE_EMAIL)){$errore_si_no .="Indirizzo non inserito o non valido<br>";}
if($errore_si_no != ""){
echo "<div class=\"ok_ko\">$errore_si_no</div>";
echo "<meta http-equiv='Refresh' content='5; URL=".htmlspecialchars($_SERVER['PHP_SELF'])."'>";
}else{
$inserimento=mysql_query("insert into Guestbook (NOME, COGNOME, MESSAGGIO, INDIRIZZO, DATA_ORA) values ('$name', '$surname', '$message', '$e_mail', now())");
if($inserimento){
$errore_si_no="Il tuo messaggio è stato inserito correttamente!<br />";
echo "<div class=\"ok_ko\">$errore_si_no</div>";
echo "<meta http-equiv='Refresh' content='5; URL=messaggigb.php'>";
}else{
$errore_si_no="Errore nell'inserimento del tuo messaggio. Riprova più tardi";
echo "<div class=\"ok_ko\">$errore_si_no</div>";
echo "<meta http-equiv='Refresh' content='3; URL=".htmlspecialchars($_SERVER['PHP_SELF'])."'>";
}
}
}
//mentre registra i dati non vedi il messaggi ed il form
?>
</p>
</div>
<!-- InstanceEndEditable -->
<div id="Footer"><p><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/it/"><img alt="Licenza Creative Commons" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-nd/3.0/it/80x15.png" /></a><br />
Il Sito è distribuito con <br />
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/it/">Licenza Creative Commons Attribuzione - Non commerciale - Non opere derivate 3.0 Italia</a>.<br />
<br />
<strong>Migliore Visualizzazione</strong>: <em>Risoluzione</em> 1024x768;<em> Browser</em> <a href="https://www.google.com/chrome?hl=it">Google Chrome</a>. <strong>Versione del sito</strong>: 2.1<br />
<br />
Problemi con il sito? <a href="comunicazioni.php">Vai qui!</a></p></div>
</div>
</body>
<!-- InstanceEnd --></html>
Ecco qui tutto il codice...