Ciao a tutti.Sto studiando php e in particolare la bellissima guida su questo sito. Alla fine della guida c'è un esempio di php dove c'è un form di inserimento di alcuni dati. Premendo invio si dovrebbe aprire un form con i dati inseriti. Invece viene visualizzato tutto il codice del secondo form.
Vi posto il codice:

the_form.php
[CODE]

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>HTML.it - Guida alla OOP con PHP5 - Classe FormCheck</title>
</head>


<body>


<h2>HTML.it - Guida alla OOP con PHP5 - Classe FormCheck</h2>


<table>
<form action="class_formcheck.php" method="post">

<tr><td>Nome:</td><td> <input type="text" name="name" /></td>
<tr><td>Cognome:</td><td> <input type="text" name="lastname" /></td>
<tr><td>E-Mail:</td><td> <input type="text" name="email" /></td>
<tr><td>Anno di nascita:</td><td> <input type="text" name="year" /></td>
<tr><td><input type="submit" value="Invia" /></td></tr>

</form>
</table>


</body>
</html>

Questo è il file che dovrebbe gestire i dati inseriti:

codice:
<?php


// HTML.it - Guida alla OOP con PHP5
// http://php.html.it/guide/leggi/167/guida-programmazione-ad-oggetti-con-php-5/
// by Riccardo Degni


// ----------------------------------------
// interfaccia IFormCheck 
// ----------------------------------------
interface IFormCheck {


	public function checkName();
	public function checkLastname();
	public function checkEMail();
	public function checkYear();
	public function checkAll();
	public function setErrorMsgs($errs);
	
}


// ----------------------------------------
// class AFormCheck
//		implements IFormCheck
// ----------------------------------------
abstract class AFormCheck implements IFormCheck {


	public $name;
	public $lastname;
	public $email;
	public $year;
	public $errorMsgs = array(
		'name' => 'Il nome deve essere composto da caratteri alfanumerici e deve contenere dai 4 ai 10 caratteri al massimo.',
		'lastname' => 'Il cognome deve essere composto da caratteri alfanumerici e deve contenere dai 4 ai 15 caratteri al massimo.',
		'email' => 'L\' e-mail deve essere composta nella seguente forma: "mailname@mailserver.mailext"',
		'year' => 'L\'anno di nascita deve essere superiore al 1900'
	);
	private $err = '';
	public $clean = array();
	
	// costruttore
	public function __construct() {
		$this->name = $_POST['name'];
		$this->lastname = $_POST['lastname'];
		$this->email = $_POST['email'];
		$this->year = $_POST['year'];
	}
	
	// metodi di tracking/erroring
	protected function trackErrorMsg($field) {
		if($this->errorMsgs[$field]) {
			$this->err .= "<p>" . $this->errorMsgs[$field] . "</p>";
		}
		else {
			$this->internalError();
		}
	}
	
	protected function getErrorMsg() {
		if($this->err != '') {
			echo "<h4>Errore!</h4>";
			echo $this->err;
			return false;
		}
		else {
			echo "<h4>Ok!</h4>";
			echo "<p>Tutti i campi del form sono stati inviati correttamente.</p>";
			return true;
		}
	}
	
	protected function internalError() {
		trigger_error('Non esiste un errore di questo tipo.', E_USER_WARNING);
	}
}


// ----------------------------------------
// class FormCheck
//		extends AFormCheck
// ----------------------------------------
class FormCheck extends AFormCheck {
	
	// metodi di checking
	public function checkName() {
		if(is_string($this->name) && ctype_alnum($this->name) && (strlen($this->name) <= 10) && (strlen($this->name) >= 4)) {
			echo "<p>Il nome è stato inviato correttamente.</p>";
			$this->clean['name'] = htmlentities($this->name, ENT_QUOTES);
		}
		else {
			$this->trackErrorMsg('name');
		}
	}
	
	public function checkLastname() {
		if(is_string($this->lastname) && ctype_alnum($this->lastname) && (strlen($this->lastname) <= 15) && (strlen($this->lastname) >= 4)) {
			echo "<p>Il cognome è stato inviato correttamente.</p>";
			$this->clean['lastname'] = htmlentities($this->lastname, ENT_QUOTES);
		}
		else {
			$this->trackErrorMsg('lastname');
		}
	}
	
	public function checkEMail() {
		if(is_string($this->email) && eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$', $this->email)) {
			echo "<p>L'e-mail è stata inviata correttamente.</p>";
			$this->clean['email'] = $this->email;
		}
		else {
			$this->trackErrorMsg('email');
		}
	}
	
	public function checkYear() {
		if((intval($this->year) >= 1900)) {
			echo "<p>L'anno di nascita è stato inviato correttamente.</p>";
			$this->clean['year'] = (int)$this->year;
		}
		else {
			$this->trackErrorMsg('year');
		}
	}
	
	public function checkAll() {
		$this->checkName();
		$this->checkLastname();
		$this->checkEMail();
		$this->checkYear();
		return $this->getErrorMsg();
	}
	
	// altro
	public function setErrorMsgs($errs) {
		foreach($errs as $err => $txt) {
			$this->errorMsgs[$err] = $txt;
		}
	}


}










// ----------------------------------------
// Implenentazione
// ----------------------------------------
$form = new FormCheck();


if(!$form->checkAll()) { 
	exit();
}
else {
	echo "<p><strong>Nome:</strong>" . $form->clean['name'] . "</p>";
	echo "<p><strong>Cognome:</strong>" . $form->clean['lastname'] . "</p>";
	echo "<p><strong>Mail:</strong>" . $form->clean['email'] . "</p>";
	echo "<p><strong>Year:</strong>" . $form->clean['year'] . "</p>";
}


?>