Ciao ragazzi ho quasi finito un controllo Captcha nel mio form e ho due problemi:
1) Inserire un bottone che mi refreshi l'immagine (creata in .php) nel caso non sia leggibile
2) Non mi funziona il controllo Captcha...anche se inserisco il codice giusto non mi va...
Allego i file che compongono il tutto contattic.php (dove c'è il form) immaginec.php (crea l'immagine e il codice) immagine_show.php (mostra l'immagine nel form) sendate1.php (invia i dati per posta se sono corretti
contattic.php
immaginec.phpCodice:<html> <head> <meta http-equiv="Content-Language" content="it"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>CONTATTI</title> </head> <body> <form method="POST" action="http://www.santadown.altervista.org/sendate1.php"> <p><font face="Calibri" style="font-size: 15pt">CONTATTI: </font></p> <table border="0" width="46%" id="table1" style="font-family: Calibri; font-size: 12pt; font-style: oblique" height="340"> <tr> <td width="149">Nome</td> <td><input type="text" name="name" size="38"></td> </tr> <tr> <td width="149">Cognome</td> <td><input type="text" name="lname" size="38"></td> </tr> <tr> <td width="149">Email</td> <td><input type="text" name="email" size="38"></td> </tr> <tr> <td width="149">Telefono</td> <td><input type="text" name="tel" size="38"></td> </tr> <tr> <td width="149">Motivo del contatto:</td> <td> <select name="motivo"> <option value="Informazioni Commerciali">Informazioni commerciali</option> <option value="Richiesta preventivo">Richiesta preventivo</option> <option value="Prenotazione Appuntamento">Prenotazione appuntamento</option> </select></td> </tr> <tr> <td width="149">Messaggio:</td> <td><textarea rows="11" name="mess" cols="29"></textarea></td> </tr> <tr> <td width="149">Inserire codice di controllo*</td> <img src="immagine_show.php"> </tr> </table> <p><input type="text" name="captcha" size="20"></p> <p> <INPUT type="submit" value="Invia"><a href="immagine_prune.php"><input type="reset" value="REFRESH" name="B2"></a></p> <p>*<font face="Arial"><span style="font-size: 9pt">il codice di controllo è uno script che impedisce ad alcuni software malevoli di intasare il sito. Se l'immagine dovesse risultare troppo distorta per una corretta comprensione del codice cliccare sul tasto REFRESH.</span></font></p> </form> </body> </html>
immagine_show.phpCodice:<?php class immagine { header("Content-type: image/png"); for($i=0;$i<6;$i++) // sei cifre { $rand = rand(65, 90); $code .= chr($rand); } $code = substr($code,0,9); $x = 200; $y = 75; $space = $x / (strlen($code)+1); $img = imagecreatetruecolor($x,$y); $bg = imagecolorallocate($img,255,255,255); $border = imagecolorallocate($img,0,0,0); $colors[] = imagecolorallocate($img,128,64,192); $colors[] = imagecolorallocate($img,192,64,128); $colors[] = imagecolorallocate($img,108,192,64); imagefilledrectangle($img,1,1,$x-2,$y-2,$bg); imagerectangle($img,0,0,$x-1,$y-2,$border); for ($i=0; $i< strlen ($code); $i++) { $color = $colors[$i % count($colors)]; imagettftext($img,28+rand(0,8),-20+rand(0,40),($i+0.3)*$space,50+rand(0,10),$color,'font.ttf',$code{$i}); } for($i=0;$i<400;$i++) { $x1 = rand(3,$x-3); $y1 = rand(3,$y-3); $x2 = $x1-2-rand(0,8); $y2 = $y1-2-rand(0,8); imageline($img,$x1,$y1,$x2,$y2,$colors[rand(0,count($colors)-1)]); } imagepng($img); $_SESSION['captcha'] = $code; } ?>
sendate1.phpCodice:<?php include("immaginec.php"); $img = new immagine(); //$img->show("trees.jpg"); $img->show(); ?>
Provate pure... l'indirizzo è www.santadown.altervista/contattic.phpCodice:<?php // Inizio sessione e termina gli errori session_start(); error_reporting(0); // Salva i dati $nome = trim($_POST['name']); $cognome = trim($_POST['lname']); $email = trim($_POST['email']); $telefono = trim($_POST['tel']); $motivo = trim($_POST['motivo']); $messaggio = trim($_POST['mess']); $captcha = trim($_POST['captcha']); // Controlla se tutti i dati sono stati inseriti if ( $nome != '' && $cognome != '' && $email != '' && $telefono != '' && $motivo != '' && $messaggio != '' && $captcha != '' ) { // Controlla se il codice di sicurezza è giusto if ( $captcha == $_SESSION['captcha'] ) { // to $to = "XXXXXXXX@gmail.com"; // Subject $subject = 'Modulo proveniente dal sito <a href="http://www.studio.it" target="_blank"><a href="http://www.studio.it" target="_blank">www.studio.it</a></a>'; // Body $body = "Contenuto del modulo:\n\n"; $body .= "Dati personali : Nome: " . stripslashes($_POST["name"]) . "\n"; $body .= "Cognome: " . stripslashes($_POST["lname"]) . "\n"; $body .= "Email: " . stripslashes($_POST["email"]) . "\n"; $body .= "Telefono: " . stripslashes($_POST["tel"]) . "\n"; $body .= "Motivo del contatto: " . stripslashes($_POST["motivo"]). "\n"; $body .= "Messaggio: " . stripslashes($_POST["mess"]) . "\n"; // Spedisce la mail if( mail($to, $subject, $body) ) echo "La mail è stata inoltrata con successo!"; else echo "Si sono verificati dei problemi nell’invio della mail."; } else echo "Codice di conferma errato"; } else echo "Invio dati fallito: prego riempire tutti i campi e riprocedere"; ?>
Grazie mille ragazzi!

LinkBack URL
About LinkBacks
