Aiuto con applicazione CAPTCHA
-
-
-
-
-
-
Allora ti preavviso che è un modulo che non fa riferimento ad un'altra pagina a parte in php, ma la sua azione è $_POST
Ho cercato di fissare la condizione che se il campo rimane vuoto il modulo non deve essere eseguito, però il modulo anche in presenza di campi vuoti viene eseguito comunque!
Di seguito ho postato il codice dello script:
<? // Show form to add your site if(!isset($_POST['submit'])) { ?> <table style="margin-top: 30px;" border="1" cellpadding="2" cellspacing="0" width="50%" class="content" align="center"> <tr class="title"> <form method="POST" name=form> <input type="hidden" name="submit" value="1"> <td width="100%" colspan="2"> <p align="center"><? echo $text['73'] ?></td> </tr> <tr> <td width="50%"><? echo $text['36'] ?> :</td> <td width="50%"><input type="text" name="sitename" size="24" maxlength="50"></td> </tr> <tr> <td width="50%"><? echo $text['37'] ?> :</td> <td width="50%"><input type="text" name="url" size="24" maxlength="100"></td> </tr> <tr> <td width="50%"><? echo $text['38'] ?> [ 88 x 31 ] :</td> <td width="50%"><input type="text" name="buttonurl" size="24" maxlength="125"></td> </tr> <tr> <td width="50%"><? echo $text['39'] ?> :</td> <td width="50%"><input type="text" name="email" size="24" maxlength="75"></td> </tr> <tr> <td width="50%"><? echo $text['137'] ?> :</td> <td width="50%"><select name="country" onChange="showimage()"><? // Selecting different flags directory 'images/flags' $handle = opendir('images/flags'); while(false!==($file = readdir($handle))) { if($file != "." AND $file != "..") { if($file == "flag_oth.gif") { $selected = " selected"; } else { $selected = " "; } echo "<option value=\"" . $file . "\"" . $selected . ">" . $file . "</option>\n"; } } closedir($handle); ?> </select><img src="images/flags/flag_oth.gif" name="icons" border="1" hspace="10"></td> </tr> <tr> <td width="50%" valign="top"><? echo $text['40'] ?> :</td> <td width="50%"><textarea rows="7" name="description" cols="26"></textarea></td> </tr> <tr> <td width="50%" valign="top"><? echo $text['22'] ?> :</td> <td width="50%"><input type="password" name="pssw" size="12" maxlength="25"></td> </tr> <tr> <td width="50%" valign="top"><? echo $text['22'] ?> [ <? echo $text['59'] ?> ]:</td> <td width="50%"><input type="password" name="pssw2" size="12" maxlength="25"></td> </tr> <tr> <td width="100%" valign="top" colspan="2"> <p align="center"><input type="submit" value="<? echo $text['72'] ?>"></td> </tr> </table> <? } // Form has been submitted if(isset($_POST['submit'])) { // Checking if email isn't used before to register a website $query = mysql_query("SELECT COUNT(1) FROM " . $table . "_sites WHERE email = '" . $_POST['email'] . "'"); $result = mysql_result($query,0); // If email has been registered, give error if(!empty($result)) { ?> <table border="1" cellpadding="2" cellspacing="0" width="50%" class="content" align="center"> <tr class="title"> <td width="100%"><p align="center"><? echo $text['73'] ?></td> </tr> <tr> <td width="100%"><? echo $text['74'] ?> ... <br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a></td> </tr> </table> <? } else { // If email hasn't been registered, run script to add site ?> <table border="1" cellpadding="2" cellspacing="0" width="50%" align="center"> <tr class="title"> <td width="100%"><p align="center"><? echo $text['73'] ?></td> </tr> <tr class="content"> <td width="100%"> <? // If sitename wasn't filled in if(empty($_POST['sitename'])) { ?> <? echo $text['75'] ?> <br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a> <? } // If URL wasn't filled in elseif(empty($_POST['url'])) { ?> <? echo $text['76'] ?> <br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a>"; <? } // If email wasn't filled in elseif(empty($_POST['email'])) { ?> <? echo $text['77'] ?> <br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a> <? } // If description wasn't filled in elseif(empty($_POST['description'])) { ?> <? echo $text['78'] ?> <br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a> <? } // If password / confirm password weren't filled in elseif(empty($_POST['pssw']) OR empty($_POST['pssw2'])) { ?> <? echo $text['79'] ?> <br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a> <? } else { // If passwords are not the same if($_POST['pssw'] != $_POST['pssw2'] OR empty($_POST['pssw']) OR empty($_POST['pssw2'])) { ?> <? echo $text['61'] ?> ... <br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a> <? } else { // Not encrypted version of password $pssw = $_POST['pssw']; // Encrypted version of password $pssw_encrypted = md5($_POST['pssw']); $_POST['country'] = str_replace("flag_","", $_POST['country']); $_POST['country'] = str_replace(".gif","", $_POST['country']); $date = date("dmY"); -
-
<? // Show form to add your site //ATTENZIONE PER OGNI DOMANDA INSERIRE UNA RISPOSTA $aDOMANDE=array('Quanto fa 10+3?', 'quale lettera è la iniziale di <b>BIANCO</b>?', 'scrivi solo la parola <b>ROMA</b>'); $aRISPOSTE=array('13', 'B', 'Roma'); $TOTALE_domande=count($aDOMANDE); $TOTALE_domande=$TOTALE_domande-1; //for ($iQ = 0; $iQ < count($righeCheck); $iQ++) { if(!isset($_POST['submit'])) { ?> <table style="margin-top: 30px;" border="1" cellpadding="2" cellspacing="0" width="50%" class="content" align="center"> <tr class="title"> <form method="POST" name=form> <input type="hidden" name="submit" value="1"> <td width="100%" colspan="2"> <p align="center"><? echo $text['73'] ?></td> </tr> <tr> <td width="50%"><? echo $text['36'] ?> :</td> <td width="50%"><input type="text" name="sitename" size="24" maxlength="50"></td> </tr> <tr> <td width="50%"><? echo $text['37'] ?> :</td> <td width="50%"><input type="text" name="url" size="24" maxlength="100"></td> </tr> <tr> <td width="50%"><? echo $text['38'] ?> [ 88 x 31 ] :</td> <td width="50%"><input type="text" name="buttonurl" size="24" maxlength="125"></td> </tr> <tr> <td width="50%"><? echo $text['39'] ?> :</td> <td width="50%"><input type="text" name="email" size="24" maxlength="75"></td> </tr> <tr> <td width="50%"><? echo $text['137'] ?> :</td> <td width="50%"><select name="country" onChange="showimage()"><? // Selecting different flags directory 'images/flags' $handle = opendir('images/flags'); while(false!==($file = readdir($handle))) { if($file != "." AND $file != "..") { if($file == "flag_oth.gif") { $selected = " selected"; } else { $selected = " "; } echo "<option value=\"" . $file . "\"" . $selected . ">" . $file . "</option>\n"; } } closedir($handle); ?> </select><img src="images/flags/flag_oth.gif" name="icons" border="1" hspace="10"></td> </tr> <tr> <td width="50%" valign="top"><? echo $text['40'] ?> :</td> <td width="50%"><textarea rows="7" name="description" cols="26"></textarea></td> </tr> <tr> <td width="50%" valign="top"><? echo $text['22'] ?> :</td> <td width="50%"><input type="password" name="pssw" size="12" maxlength="25"></td> </tr> <tr> <td width="50%" valign="top"><? echo $text['22'] ?> [ <? echo $text['59'] ?> ]:</td> <td width="50%"><input type="password" name="pssw2" size="12" maxlength="25"></td> </tr> <tr> <td width="100%" valign="top" colspan="2"> Sei umano?<br> <? $idDomanda=rand(0,$TOTALE_domande); echo $aDOMANDE[$idDomanda]; ?> <input type="text" name="risposta" size="40" maxlength="100"> <input type="Hidden" name="idDomanda" value="<? echo $idDomanda; ?>"> </td> </tr> <tr> <td width="100%" valign="top" colspan="2"> <p align="center"><input type="submit" value="<? echo $text['72'] ?>"></td> </tr> </table> <? } // Form has been submitted if(isset($_POST['submit']) and isset($_POST['sitename']) and isset($_POST['url'])) //con [ and isset($_POST['nomeCAMPO']) ] aggiungi i campi che devono essere riempiti per l'invio del form { //CONDIZIONE DI CONTROLLO DELLA PAGINA RANDOM uso strtolower() per evitare problemi di scrittura tar minuscolo e maiuscolo strtolower() trasforma tutto in minuscolo if( strtolower($aRISPOSTE[$idDomanda]) != strtolower($_POST['risposta']) ) { //stampo l'errore magari quello lo peronalizzi (non ho capito la logica...) echo strtolower($aRISPOSTE[$idDomanda])."<br>"; echo strtolower($_POST['risposta'])."<br>"; ?> <table border="1" cellpadding="2" cellspacing="0" width="50%" class="content" align="center"> <tr class="title"> <td width="100%"><p align="center">ERRORE....</td> </tr> <tr> <td width="100%">La risposta non è corretta ... <br><br><a href="post.php"><< torna indietro</a></td> </tr> </table> <? } else { // Checking if email isn't used before to register a website $query = mysql_query("SELECT COUNT(1) FROM " . $table . "_sites WHERE email = '" . $_POST['email'] . "'"); $result = mysql_result($query,0); // If email has been registered, give error if(!empty($result)) { ?> <table border="1" cellpadding="2" cellspacing="0" width="50%" class="content" align="center"> <tr class="title"> <td width="100%"><p align="center"><? echo $text['73'] ?></td> </tr> <tr> <td width="100%"><? echo $text['74'] ?> ... <br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a></td> </tr> </table> <? } else { // If email hasn't been registered, run script to add site ?> <table border="1" cellpadding="2" cellspacing="0" width="50%" align="center"> <tr class="title"> <td width="100%"><p align="center"><? echo $text['73'] ?></td> </tr> <tr class="content"> <td width="100%"> <? // If sitename wasn't filled in if(empty($_POST['sitename'])) { ?> <? echo $text['75'] ?> <br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a> <? } // If URL wasn't filled in elseif(empty($_POST['url'])) { ?> <? echo $text['76'] ?> <br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a>"; <? } // If email wasn't filled in elseif(empty($_POST['email'])) { ?> <? echo $text['77'] ?> <br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a> <? } // If description wasn't filled in elseif(empty($_POST['description'])) { ?> <? echo $text['78'] ?> <br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a> <? } // If password / confirm password weren't filled in elseif(empty($_POST['pssw']) OR empty($_POST['pssw2'])) { ?> <? echo $text['79'] ?> <br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a> <? } else { // If passwords are not the same if($_POST['pssw'] != $_POST['pssw2'] OR empty($_POST['pssw']) OR empty($_POST['pssw2'])) { ?> <? echo $text['61'] ?> ... <br><br><a href="javascript:history.go(-1)"><< <? echo $text['20'] ?></a> <? } else { // Not encrypted version of password $pssw = $_POST['pssw']; // Encrypted version of password $pssw_encrypted = md5($_POST['pssw']); $_POST['country'] = str_replace("flag_","", $_POST['country']); $_POST['country'] = str_replace(".gif","", $_POST['country']); $date = date("dmY"); } } } } } ?> -
Non ho capito in questa parte
<table border="1" cellpadding="2" cellspacing="0" width="50%" class="content" align="center"> <tr class="title"> <td width="100%"><p align="center">ERRORE....</td> </tr> <tr> <td width="100%">La risposta non è corretta ... <br><br><a href="post.php"><< torna indietro</a></td> </tr> </table>perchè fai riferimento a post.php?
Cmq ti ho allegato il file intero dello script cosi ne capisci per intero la sua logica...;)
NB: puntualizzo che la pagina che ti ho allegato contiene un form che permette alla gente di iscriversi ad una classifica! Questo file fa riferimento anche ad un file di installazione, che ha creato le tabelle nel mio db mysql)
-
Scusa ma lo script che ti ho inviato è già funzionante...
la parte
<table border="1" cellpadding="2" cellspacing="0" width="50%" class="content" align="center"> <tr class="title"> <td width="100%"><p align="center">ERRORE....</td> </tr> <tr> <td width="100%">La risposta non è corretta ... <br><br><a href="post.php"><< torna indietro</a></td> </tr> </table>la puoi personalizzare da solo
post.php è il nome della pagina che ho usato io per la prova li puoi mettere quelo che vuoiper il resto lo script funziona...
-
-
??? ma dico ??? ma il lavoro è tuo? o è mio?
no perchè mi sta venendo un dubbio...comunque il file che mi hai invato non funziona e da errore perchè mancano dei file di inclusione...
non puoi mica scaricar il lavoro così se vuoi un aiuto devi anche collaborare
io sullo script che mi hai inviato all'inizio ho realizzato un sistema funzionante ora potresti anche provare ad inserirlo tu nel tuo progetto
se poi trovi dei problemi come hai fatto prima scirivi e dici che problemi hai trovato e via via si cerca di darti una mano ma per favore collabora!
-
Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.
Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.
Con il tuo contributo, questo post potrebbe essere ancora migliore 💗
Registrati Accedi