Grazie mille per l'aiuto. Purtroppo non compare nulla...
Credo che il problema sia qui :
Codice PHP:
function leggi_dati() { $html_form_immissione = '
dato che il codice va messo fra apici...
Ti riporto comunque le parti del codice interessate, così magari puoi suggerirmi qualcos'altro:
Per l'inserimento, ho modificato da riga 241 del codice originale così:
Codice PHP:
// Inserire nuovo commento
function aggiungi_record(){
$test_non_vuoto = trim($_POST["nome"].$_POST["commento"]);
if( (!isset($_POST["recaptcha_response_field"])) or (empty($_POST["recaptcha_response_field"])) ){
exit('input inesistente');
//return FALSE;
}
/*imposti la key privata*/
$_RECAPTCHA['privatekey'] = "qui-ho-messo-il-mio-codice";
/*includi la libreria*/
require_once('recapchalib.php');
# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;
$resp = recaptcha_check_answer ($_RECAPTCHA['privatekey'],
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if(!$resp->is_valid){
exit('errore nel capcha');
}
if ($test_non_vuoto != "") {
$this->linea = $this->separatore_righe.$_POST["dataora"].$this->separatore_campi.$_POST["nome"].$this->separatore_campi.$_POST["email"].$this->separatore_campi.$_POST["citta"].$this->separatore_campi.$_POST["contatto"].$this->separatore_campi.$_POST["commento"]."\r\n";
$puntatore = fopen($this->nomefile, "a");
$this->linea = $this->striptags($this->linea);
fputs($puntatore, $this->linea);
fclose($puntatore);
L'altra modifica (che come ho detto prima penso sia quella sbagliata) parte dalla riga 253 del codice originale. Ho dovuto inserire dei backslash nel tuo codice altrimenti mi dava errore:
codice:
// metodo per la raccolta dati di un nuovo record
function leggi_dati() {
$html_form_immissione = '
<script language="JavaScript">
<!--
function controlla() {
if ((document.inseriscirecord.nome.value == \'\') || (document.inseriscirecord.commento.value == \'\')) {
alert(\'inserisci almeno il nome e un commento!\');
return false;
} else {
return true;
}
}
//-->
</script>
<form method="post" action="guestbook.php" name="inseriscirecord" onSubmit="return controlla();">
<table border="0" width="'.($this->larghezza_tabella - 2).'" cellspacing="1" cellpadding="4" class="tabellainterna">
<tr>
<td colspan="2" class="intestazione" width="'.($this->larghezza_tabella - 2).'">
Firma il nostro guestbook!
</td>
</tr>
[non riporto qui l'intero codice per motivi di lunghezza]
<tr>
<th align="left" valign="top">
commenti:
</th>
<td>
<textarea name="commento" rows="5" cols="45" class="areatesto"></textarea>
</td>
</tr>
<tr>
<?php
/*imposti le key pubblica*/
$_RECAPTCHA[\'publickey\'] = "6LecqdISAAAAAIIJSNOHjLzHtvA4tjT5yKvxNTyj";
/*includi la libreria*/
require_once(\'recaptchalib.php\');
# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;
recaptcha_get_html($_RECAPTCHA[\'publickey\'], $error);
?>
<tr>
<td colspan="2" class="intestazione">
<input type="hidden" value="inserimento" name="azione">
<input type="hidden" name="dataora" value="'.$this->dataora_attuale().'">
<input type="submit" name="postati" value="vai !" class="pulsanti">
<input type="reset" name="cancell" value="cancella" class="pulsanti">
</td>
</tr>
</table>
</form>
';
return $html_form_immissione;
}
}
$guests = new guestbook();
if (isset($_POST["azione"]) && ($_POST["azione"] == "inserimento")) {
$guests->aggiungi_record();
}
$html = "<table><tr><td>";
if (isset($_POST["azione"]) && ($_POST["azione"] == "dettagli")) {
$html .= $guests->mostra_record($_POST["indice"]);
} else {
$html .= $guests->mostra_lista();
}
$html .= "</td></tr><tr><td>";
$html .= $guests->leggi_dati();
$html .= "</td></tr></table>";
unset($guests);