uisneach Posted November 6, 2008 Share Posted November 6, 2008 Hello. I got a form like this. It' s a drop down menu. (i took out other menus like day and hours, to make it simple) <form action='form2.php' method='POST'> <select name='year'> <option value='2004'>2008</option> <option value='2005'>2005</option> <option value='2006'>2006</option> <option value='2007'>2007</option> <option value='2007'>2008</option> </select>"; <select name='month'> <option value='10'>october</option> <option value='11'>november</option> <option value='12'>december</option> </select>"; <input name='submit' type='submit' value='send' /> <input type='hidden' name='submitted' value='yes' /> </form>"; My main question is how to insert a captcha script here. I got some problems. I really don't know how to begin. Sorry, I am newbie. Anyone has some clue/Advice/suggestion to give me? It's reallyt a bit tricky for me. Thx in advance. Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/ Share on other sites More sharing options...
rhodesa Posted November 6, 2008 Share Posted November 6, 2008 Try using something like this: http://www.phpcaptcha.org/ Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/#findComment-684032 Share on other sites More sharing options...
uisneach Posted November 6, 2008 Author Share Posted November 6, 2008 Thx i will have a glance later Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/#findComment-684180 Share on other sites More sharing options...
uisneach Posted November 8, 2008 Author Share Posted November 8, 2008 Hello. I got the captcha script from secuimage. It works ...but the problem is to adapt the scrpt to my website. This is the example form taken from the tutorial. <?php if (empty($_POST)) { ?> <form method="POST"> Username:<br /> <input type="text" name="username" /><br /> Password:<br /> <input type="text" name="password" /><br /> <!-- pass a session id to the query string of the script to prevent ie caching --> <img src="securimage_show.php?sid=<?php echo md5(uniqid(time())); ?>"><br /> <input type="text" name="code" /><br /> <input type="submit" value="Submit Form" /> </form> <?php } else { //form is posted include("securimage.php"); $img = new Securimage(); $valid = $img->check($_POST['code']); if($valid == true) { echo "<center>Thanks, you entered the correct code.</center>"; } else { echo "<center>Sorry, the code you entered was invalid. <a href=\"javascript:history.go(-1)\">Go back</a> to try again.</center>"; } } ?> Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/#findComment-685350 Share on other sites More sharing options...
uisneach Posted November 8, 2008 Author Share Posted November 8, 2008 I MADE like this but it gives an error session_start(); <form action='form2.php' method='POST'> <select name='year'> <option value='2004'>2008</option> <option value='2005'>2005</option> <option value='2006'>2006</option> <option value='2007'>2007</option> <option value='2007'>2008</option> </select>"; <select name='month'> <option value='10'>october</option> <option value='11'>november</option> <option value='12'>december</option> </select>"; <input name='submit' type='submit' value='send' /> <input type='hidden' name='submitted' value='yes' /> </form>"; <img src="securimage_show.php?sid=<?php echo md5(uniqid(time())); ?>"><br /> <input type="text" name="code" /><br /> <?php include("securimage.php"); $img = new Securimage(); $valid = $img->check($_POST['code']); if($valid == true) { echo "<center>Thanks, you entered the correct code.</center>"; } else { echo "<center>Sorry, the code you entered was invalid. <a href=\"javascript:history.go(-1)\">Go back</a> to try again.</center>"; } Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/#findComment-685353 Share on other sites More sharing options...
uisneach Posted November 8, 2008 Author Share Posted November 8, 2008 HELLO I followed the tutorial step by step but it does not work http://www.phpcaptcha.org/documentation/quickstart/#comment-388 that what happens: Hello Thx for your tutorial It’s good for the front-end section but failed on back end I strictly followed your suggstions and put the script /* captcha*/ include_once $_SERVER['DOCUMENT_ROOT'] . ‘/securimage/securimage.php’; $securimage = new Securimage(); if ($securimage->check($_POST['captcha_code']) == false) { // the code was incorrect // handle the error accordingly with your other error checking // or you can do something really basic like this die(’The code you entered was incorrect. Go back and try again.’); } on the php file that processes my form but it doesn’t work that’s the error: Warning: include_once(/securimage/securimage.php) [function.include-once]: failed to open stream: No such file or directory in D:\Inetpub\webs\istrionicocom\form2.php on line 57 Warning: include_once() [function.include]: Failed opening ‘/securimage/securimage.php’ for inclusion (include_path=’.;c:\php\includes’) in D:\Inetpub\webs\istrionicocom\form2.php on line 57 Fatal error: Class ‘Securimage’ not found in D:\Inetpub\webs\istrionicocom\form2.php on line 59 Anyone has a clue? regards paolo Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/#findComment-685392 Share on other sites More sharing options...
Yesideez Posted November 8, 2008 Share Posted November 8, 2008 http://www.pictureinthesky.net/external/phpfreaks/ivan_captcha.zip That's a captcha script I wrote and there should be a sample script in there showing how to use it. One of the features of this script is that it uses TTF (TrueType Fonts) that can be downloaded off the net or from the fonts folder on your computer. To see the script working try sending a message or signing the guestbook on my website: http://www.pictureinthesky.net Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/#findComment-685442 Share on other sites More sharing options...
uisneach Posted November 8, 2008 Author Share Posted November 8, 2008 Hello. Sorry, but as a noob i don't understand always how inserting the script that is the problem. I saw image created, but what i do? thanks in advance p. Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/#findComment-685462 Share on other sites More sharing options...
Yesideez Posted November 8, 2008 Share Posted November 8, 2008 signguestbook.php That's a cut-down version of the script used on my website. Where the image is used on the page I'm calling the next file IMG within HTML: <img src="includes/makeimg.php" alt="" width="130" height="34" border="0" /> Inside this script you can find this line: if (md5($_POST['vcode'])==$_SESSION['vercode']) { This checks the MD5 hash of the text entered by the user against the MD5 hash of the text inside the captcha image. If it matches it carries on checking the rest of the information and if it fails it tells the user the code doesn't match. makeimg.php This is the script that makes the captcha image. This needs to access the TTF font so have that inside a FONT folder wherever you put this script. Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/#findComment-685475 Share on other sites More sharing options...
uisneach Posted November 8, 2008 Author Share Posted November 8, 2008 You just forgive me, but it works only because the image is loaded ??? But i don't undesrtand how to control and verify if the data are correct Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/#findComment-685518 Share on other sites More sharing options...
Yesideez Posted November 8, 2008 Share Posted November 8, 2008 When you call makeimg.php it runs the makeimg.php script and that makes a random string and stores its MD5 hash inside a session variable. It is the if() statement that checks what you entered against the session variable. Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/#findComment-685526 Share on other sites More sharing options...
uisneach Posted November 8, 2008 Author Share Posted November 8, 2008 Yes, i got it. but i have to add this inside the form? <input type='text' name='vercode' size='10' maxlength='6' /> The box where putting the code Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/#findComment-685532 Share on other sites More sharing options...
Yesideez Posted November 8, 2008 Share Posted November 8, 2008 No, "vercode" is created using the makeimg script and is a session variable. Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/#findComment-685533 Share on other sites More sharing options...
uisneach Posted November 8, 2008 Author Share Posted November 8, 2008 Thanks but the situation is not changing: after loading on my url all the files and entering the line , appears only the image. have a look if you want so you can understand better the situation here my website with your image So, you got the issue- http://www.istrionico.com/inserisci2.php Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/#findComment-685538 Share on other sites More sharing options...
Yesideez Posted November 8, 2008 Share Posted November 8, 2008 OK the onew thing I see missing is the input box so the user can type in the captcha code - apologies if that is what you meant! <input type="text" name="vcode" size="8" maxlength="6" /> Add that somewhere near the captcha image. Don't forget to name the text box what you want to use it in the script. Again, sorry for the confusion! Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/#findComment-685543 Share on other sites More sharing options...
Yesideez Posted November 8, 2008 Share Posted November 8, 2008 One last thing I forgot to mention... This line inside makeimg.php: $chars='abcdefghijkmnqrstuvwxyz0123456789ABCDEFGHIJKLMNPQRSTUVWXYZ'; Those characters are those that will be used inside the captcha - change this to what you want to appear inside the image. You can change the font to whatever you want to use by uploading a different one but it must be TTF. Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/#findComment-685546 Share on other sites More sharing options...
uisneach Posted November 8, 2008 Author Share Posted November 8, 2008 Thx again. :)Now the question of the box is solved but the problem is that if you enter a wrong code, there is no any control or verifying how come? It is missing anything? it miss the control? Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/#findComment-685558 Share on other sites More sharing options...
Yesideez Posted November 8, 2008 Share Posted November 8, 2008 I think now is the time to post the script so I can suggest the best place to add the verification check. Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/#findComment-685562 Share on other sites More sharing options...
uisneach Posted November 8, 2008 Author Share Posted November 8, 2008 Yes sorry Here is the form <!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/Speciali.dwt" codeOutsideHTMLIsLocked="false" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Inserisci i dati: soppressioni</title> <link href="passante.css" rel="stylesheet" type="text/css"/> </head> <body> <div class="testata"></div> <div class="menu"> <a href="http://segratrain.altervista.org/index.html">Home</a> <a href="http://www.istrionico.com/inserisci2.php">Inserisci Soppressione</a> <a href="http://www.istrionico.com/listasoppressioni.php">Archivio Soppressioni</a> <a href="http://www.istrionico.com/inserisci.php">Inserisci Ritardo</a> <a href="http://www.istrionico.com/listaritardi.php">Archivio Ritardi</a> <a href="http://segratrain.altervista.org/news.html">News</a> <a href="http://segratrain.altervista.org/documenti.html">Documenti</a> <a href="http://segratrain.altervista.org/contatti.html">Contatti</a> </div> <div class="centrale2"> <div class="sinistra2"><div class="altosx6"></div> <br /> <?php session_start(); // SETTO I DATI PER LA CONFIGURAZIONE DELLA CONNESSIONE CREANDO LE RELATIVE VARIABILI $host = ""; $user = ""; $password = ""; $dbname = ""; //CREO LA VARIABILE CHE CONNETTE IL SERVER AL DATABASE $cxn = mysql_connect($host,$user,$password); mysql_select_db($dbname); //CONTROLLO CONNESSIONE SE è OK if (!$cxn) { echo 'Errore durante la connessione al server MySQL'; exit(); } else { echo ''; } echo "<span style='font-family:arial'/>Inserisci i dati del treno SOPPRESSO </span>"; echo "<p style='font-family:arial'> <form action='form2.php' method='POST'> <select name='giorno'> <option value='01'>1</option> <option value='02'>2</option> <option value='03'>3</option> <option value='04'>4</option> <option value='05'>5</option> <option value='06'>6</option> <option value='07'>7</option> <option value='08'>8</option> <option value='09'>9</option> <option value='10'>10</option> <option value='11'>11</option> <option value='12'>12</option> <option value='13'>13</option> <option value='14'>14</option> <option value='15'>15</option> <option value='16'>16</option> <option value='17'>17</option> <option value='18'>18</option> <option value='19'>19</option> <option value='20'>20</option> <option value='21'>21</option> <option value='22'>22</option> <option value='23'>23</option> <option value='24'>24</option> <option value='25'>25</option> <option value='26'>26</option> <option value='27'>27</option> <option value='28'>28</option> <option value='29'>29</option> <option value='30'>30</option> <option value='31'>31</option> </select>"; echo "Giorno <select name='mese'> <option value='10'>ottobre</option> <option value='11'>novembre</option> <option value='12'>dicembre</option> </select>"; echo "Mese <select name='anno'> <option value='2008'>2008</option> </select>"; echo "anno <br /><br /> <select name='direzione'> <option value='Pioltello'>Pioltello</option> <option value='Varese'>Varese</option> </select>"; echo "Direzione <br /><br /> <select name='orario'> <option value='0614'>6.14</option> <option value='0644'>6.44</option> <option value='0714'>7.14</option> <option value='0744'>7.44</option> <option value='0814'>8.14</option> <option value='0844'>8.44</option> <option value='0914'>9.14</option> <option value='0944'>9.44</option> <option value='1014'>10.14</option> <option value='1044'>10.44</option> <option value='1114'>11.14</option> <option value='1144'>11.44</option> <option value='1214'>12.14</option> <option value='1244'>12.44</option> <option value='1314'>13.14</option> <option value='1344'>13.44</option> <option value='1414'>14.14</option> <option value='1444'>14.44</option> <option value='1514'>15.14</option> <option value='1544'>15.44</option> <option value='1614'>16.14</option> <option value='1644'>16.44</option> <option value='1714'>17.14</option> <option value='1744'>17.44</option> <option value='1814'>18.14</option> <option value='1844'>18.44</option> <option value='1914'>19.14</option> <option value='1944'>19.44</option> <option value='2014'>20.14</option> <option value='2044'>20.44</option> <option value='2114'>21.14</option> <option value='2144'>21.44</option> <option value='2214'>22.14</option> <option value='2244'>22.44</option> <option value='2314'>23.14</option> <option value='2344'>23.44</option> <option value='0014'>.00.14</option> </select>"; echo "Orario *<br/ > <br /> <select name='annunciata'> <option value='si'>Si</option> <option value='no'>No</option> </select>"; echo "Annunciata<br /> <br /> <br /> <img src='includes/makeimg.php' alt='captcha' width='130' height='34' border='0 /> <input type='hidden' name='submitted' value='yes' /> <br /><br /> <input type='text' name='vcode' size='8' maxlength='6' /><br />verifica codice <input name='submit' type='submit' value='invia' /><br /> </form>"; ?> <br /> <br /> <br /> <br /> <h4 class="pippo">* Nota: L'orario verso Pioltello è diverso: .15 o .45 invece che .14 o .44; Ma, dato che pochissima gente utilizza il treno in direzione Pioltello,<br /> si è deciso di lasciare un solo orario di riferimento, quello per Varese ma si puo' utilizzare anche per il Treno in direzione Pioltello</h4> </div> </div> <div class="footer" > <a href="maito:[email protected]">[email protected]</a></div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/#findComment-685570 Share on other sites More sharing options...
uisneach Posted November 8, 2008 Author Share Posted November 8, 2008 and this is the php file that makes the form working <!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/Speciali.dwt" codeOutsideHTMLIsLocked="false" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Inserisci i dati:ritardi</title> <link href="passante.css" rel="stylesheet" type="text/css"/> </head> <body> <div class="testata"></div> <div class="menu"> <a href="http://segratrain.altervista.org/index.html">Home</a> <a href="http://www.istrionico.com/inserisci2.php">Inserisci Soppressione</a> <a href="http://www.istrionico.com/listasoppressioni.php">Archivio Soppressioni</a> <a href="http://www.istrionico.com/inserisci.php">Inserisci Ritardo</a> <a href="http://www.istrionico.com/listaritardi.php">Archivio Ritardi</a> <a href="http://segratrain.altervista.org/news.html">News</a> <a href="http://segratrain.altervista.org/documenti.html">Documenti</a> <a href="http://segratrain.altervista.org/contatti.html">Contatti</a> </div> <div class="centrale"> <div class="sinistra2"><div class="altosx6"></div> <br /> <? require ('config.php'); $giorno = $_POST['giorno']; $mese = $_POST['mese']; $anno = $_POST['anno']; $orario = $_POST['orario']; $direzione = $_POST['direzione']; $annunciata = $_POST ['annunciata']; $var = $annunciata; if ($var == 'si'){ $si = 1; $no = 0; } else { $si = 0; $no = 1; } /* captcha*/ /* Controllo IP */ $Ip_address = $_SERVER['REMOTE_ADDR']; /* Controllo se un utente inserisce una data o un'ora non ancora passata */ $time = strtotime("now"); $then = strtotime("$giorno-$mese-$anno-$orario"); if ($then > $time) { echo "Questo treno non è ancora passato, fai un altro inserimento"; exit(); } else { //okay } /* Controllo se un utente inserisce un giorno sbagliato esempio 31 novembre */ if (($mese == '11') && ($giorno == '31')){ echo "<br />"; echo "<p> Non esiste quel giorno. Per favore, controlla il tuo inserimento"; die(); } else { echo ""; } /* Controllo se è già presente l'id del treno */ $sql1="SELECT * FROM treni_soppressione WHERE giorno = '$giorno' AND mese = '$mese' AND anno = '$anno' AND orario = '$orario' AND direzione = '$direzione'"; $risultato = mysql_query ($sql1); $num_righe = mysql_num_rows($risultato); if($num_righe == 0) { /* se non è stato ancora inserito quel particolare treno , creo la nuova combinazione nel database*/ $sql = "INSERT INTO treni_soppressione (giorno,mese,anno,orario,direzione,annunciata,no,si) VALUES ('$giorno','$mese','$anno','$orario','$direzione','$annunciata','$no','$si')"; $result = mysql_query($sql); /* faccio inserimento dell'indirizzo IP dell'utente che inserisce dati treni*/ $inserisciIp = "INSERT INTO controllo_ip_treni_sop (ip, giorno, mese, anno, orario, direzione) VALUES ('$Ip_address','$giorno','$mese','$anno','$orario','$direzione')"; $result = mysql_query ($inserisciIp); } else{ /* Altrimenti aumento il numero di segnalazioni*/ /* Ma prima controllo se un utente con un certo ip voglia segnalare lo stesso treno due volte*/ $controllaIP = "SELECT * FROM controllo_ip_treni_sop WHERE ip='$Ip_address' AND giorno = '$giorno' AND mese = '$mese' AND anno = '$anno' AND orario = '$orario' AND direzione = '$direzione'"; $risIP = mysql_query ($controllaIP); $num_righe2 = mysql_num_rows($risIP); if ($num_righe2 == 0) { $sql2 ="UPDATE treni_soppressione SET no=(no+'$no'), si=(si+'$si') WHERE giorno = '$giorno' AND mese = '$mese' AND anno = '$anno' AND orario = '$orario' AND direzione = '$direzione' "; $result2 = mysql_query($sql2); $sicontr="SELECT * FROM treni_soppressione WHERE giorno = '$giorno' AND mese = '$mese' AND anno = '$anno' AND orario = '$orario' AND direzione = '$direzione'"; $pippo = mysql_query ($sicontr); $sql5 = mysql_fetch_row ($pippo); if ($sql5[8] >= $sql5[7]) { $sql3 = "UPDATE treni_soppressione SET annunciata = 'si' WHERE giorno = '$giorno' AND mese = '$mese' AND anno = '$anno' AND orario = '$orario' AND direzione = '$direzione' "; $result3 = mysql_query($sql3); } else { $sql6 ="UPDATE treni_soppressione SET annunciata = 'no' WHERE giorno = '$giorno' AND mese = '$mese' AND anno = '$anno' AND orario = '$orario' AND direzione = '$direzione' "; $result4 = mysql_query($sql6); } } else { echo "Hai appena inserito una segnalazione per quel treno."; exit(); } } echo "<span style='font-family: arial';>grazie per la segnalazione</span></br>"; echo "<span style='font-family: arial';><a href='http://segratrain.altervista.org/'>torna alla pagina principale</a></span>"; ?> </div> <div class="footer" ><a href="maito:[email protected]">[email protected]</a></div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/#findComment-685573 Share on other sites More sharing options...
Yesideez Posted November 8, 2008 Share Posted November 8, 2008 Please edit and surround with [ code] and [ /code] tags please!!! Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/#findComment-685575 Share on other sites More sharing options...
uisneach Posted November 8, 2008 Author Share Posted November 8, 2008 sorry really. I hope to understand what you mean Here is the form [ code] <?php session_start(); // SETTO I DATI PER LA CONFIGURAZIONE DELLA CONNESSIONE CREANDO LE RELATIVE VARIABILI $host = ""; $user = ""; $password = ""; $dbname = ""; //CREO LA VARIABILE CHE CONNETTE IL SERVER AL DATABASE $cxn = mysql_connect($host,$user,$password); mysql_select_db($dbname); //CONTROLLO CONNESSIONE SE è OK if (!$cxn) { echo 'Errore durante la connessione al server MySQL'; exit(); } else { echo ''; } echo "<span style='font-family:arial'/>Inserisci i dati del treno SOPPRESSO </span>"; echo "<p style='font-family:arial'> <form action='form2.php' method='POST'> <select name='giorno'> <option value='01'>1</option> <option value='02'>2</option> <option value='03'>3</option> <option value='04'>4</option> <option value='05'>5</option> <option value='06'>6</option> <option value='07'>7</option> <option value='08'>8</option> <option value='09'>9</option> <option value='10'>10</option> <option value='11'>11</option> <option value='12'>12</option> <option value='13'>13</option> <option value='14'>14</option> <option value='15'>15</option> <option value='16'>16</option> <option value='17'>17</option> <option value='18'>18</option> <option value='19'>19</option> <option value='20'>20</option> <option value='21'>21</option> <option value='22'>22</option> <option value='23'>23</option> <option value='24'>24</option> <option value='25'>25</option> <option value='26'>26</option> <option value='27'>27</option> <option value='28'>28</option> <option value='29'>29</option> <option value='30'>30</option> <option value='31'>31</option> </select>"; echo "Giorno <select name='mese'> <option value='10'>ottobre</option> <option value='11'>novembre</option> <option value='12'>dicembre</option> </select>"; echo "Mese <select name='anno'> <option value='2008'>2008</option> </select>"; echo "anno <br /><br /> <select name='direzione'> <option value='Pioltello'>Pioltello</option> <option value='Varese'>Varese</option> </select>"; echo "Direzione <br /><br /> <select name='orario'> <option value='0614'>6.14</option> <option value='0644'>6.44</option> <option value='0714'>7.14</option> <option value='0744'>7.44</option> <option value='0814'>8.14</option> <option value='0844'>8.44</option> <option value='0914'>9.14</option> <option value='0944'>9.44</option> <option value='1014'>10.14</option> <option value='1044'>10.44</option> <option value='1114'>11.14</option> <option value='1144'>11.44</option> <option value='1214'>12.14</option> <option value='1244'>12.44</option> <option value='1314'>13.14</option> <option value='1344'>13.44</option> <option value='1414'>14.14</option> <option value='1444'>14.44</option> <option value='1514'>15.14</option> <option value='1544'>15.44</option> <option value='1614'>16.14</option> <option value='1644'>16.44</option> <option value='1714'>17.14</option> <option value='1744'>17.44</option> <option value='1814'>18.14</option> <option value='1844'>18.44</option> <option value='1914'>19.14</option> <option value='1944'>19.44</option> <option value='2014'>20.14</option> <option value='2044'>20.44</option> <option value='2114'>21.14</option> <option value='2144'>21.44</option> <option value='2214'>22.14</option> <option value='2244'>22.44</option> <option value='2314'>23.14</option> <option value='2344'>23.44</option> <option value='0014'>.00.14</option> </select>"; echo "Orario *<br/ > <br /> <select name='annunciata'> <option value='si'>Si</option> <option value='no'>No</option> </select>"; echo "Annunciata<br /> <br /> <br /> <img src='includes/makeimg.php' alt='captcha' width='130' height='34' border='0 /> <input type='hidden' name='submitted' value='yes' /> <br /><br /> <input type='text' name='vcode' size='8' maxlength='6' /><br />verifica codice <input name='submit' type='submit' value='invia' /><br /> </form>"; ?> [ /code] <br /> <br /> <br /> <br /> <h4 class="pippo">* Nota: L'orario verso Pioltello è diverso: .15 o .45 invece che .14 o .44; Ma, dato che pochissima gente utilizza il treno in direzione Pioltello,<br /> si è deciso di lasciare un solo orario di riferimento, quello per Varese ma si puo' utilizzare anche per il Treno in direzione Pioltello</h4> </div> </div> <div class="footer" > <a href="maito:[email protected]">[email protected]</a></div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/#findComment-685577 Share on other sites More sharing options...
Yesideez Posted November 8, 2008 Share Posted November 8, 2008 From what I can see so far I see this code in the second script: $giorno = $_POST['giorno']; $mese = $_POST['mese']; $anno = $_POST['anno']; $orario = $_POST['orario']; $direzione = $_POST['direzione']; $annunciata = $_POST ['annunciata']; From then on I presume (I can't read - Italian?) you're validating the data sent from the form. If I'm right, check the code the user entered with the one in the captcha code immediately after the above code I just posted. Remember, the session variable contains just the MD5 hash so you'd check it with this: if (md5($usercode)==$_SESSION['vercode']) { //code right } else { //code wrong } btw, when posting code use [code] and [/code]. Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/#findComment-685578 Share on other sites More sharing options...
uisneach Posted November 8, 2008 Author Share Posted November 8, 2008 <? require ('config.php'); $giorno = $_POST['giorno']; $mese = $_POST['mese']; $anno = $_POST['anno']; $orario = $_POST['orario']; $direzione = $_POST['direzione']; $annunciata = $_POST ['annunciata']; $var = $annunciata; if ($var == 'si'){ $si = 1; $no = 0; } else { $si = 0; $no = 1; } /* captcha*/ /* Controllo IP */ $Ip_address = $_SERVER['REMOTE_ADDR']; /* Controllo se un utente inserisce una data o un'ora non ancora passata */ $time = strtotime("now"); $then = strtotime("$giorno-$mese-$anno-$orario"); if ($then > $time) { echo "Questo treno non è ancora passato, fai un altro inserimento"; exit(); } else { //okay } /* Controllo se un utente inserisce un giorno sbagliato esempio 31 novembre */ if (($mese == '11') && ($giorno == '31')){ echo "<br />"; echo "<p> Non esiste quel giorno. Per favore, controlla il tuo inserimento"; die(); } else { echo ""; } /* Controllo se è già presente l'id del treno */ $sql1="SELECT * FROM treni_soppressione WHERE giorno = '$giorno' AND mese = '$mese' AND anno = '$anno' AND orario = '$orario' AND direzione = '$direzione'"; $risultato = mysql_query ($sql1); $num_righe = mysql_num_rows($risultato); if($num_righe == 0) { /* se non è stato ancora inserito quel particolare treno , creo la nuova combinazione nel database*/ $sql = "INSERT INTO treni_soppressione (giorno,mese,anno,orario,direzione,annunciata,no,si) VALUES ('$giorno','$mese','$anno','$orario','$direzione','$annunciata','$no','$si')"; $result = mysql_query($sql); /* faccio inserimento dell'indirizzo IP dell'utente che inserisce dati treni*/ $inserisciIp = "INSERT INTO controllo_ip_treni_sop (ip, giorno, mese, anno, orario, direzione) VALUES ('$Ip_address','$giorno','$mese','$anno','$orario','$direzione')"; $result = mysql_query ($inserisciIp); } else{ /* Altrimenti aumento il numero di segnalazioni*/ /* Ma prima controllo se un utente con un certo ip voglia segnalare lo stesso treno due volte*/ $controllaIP = "SELECT * FROM controllo_ip_treni_sop WHERE ip='$Ip_address' AND giorno = '$giorno' AND mese = '$mese' AND anno = '$anno' AND orario = '$orario' AND direzione = '$direzione'"; $risIP = mysql_query ($controllaIP); $num_righe2 = mysql_num_rows($risIP); if ($num_righe2 == 0) { $sql2 ="UPDATE treni_soppressione SET no=(no+'$no'), si=(si+'$si') WHERE giorno = '$giorno' AND mese = '$mese' AND anno = '$anno' AND orario = '$orario' AND direzione = '$direzione' "; $result2 = mysql_query($sql2); $sicontr="SELECT * FROM treni_soppressione WHERE giorno = '$giorno' AND mese = '$mese' AND anno = '$anno' AND orario = '$orario' AND direzione = '$direzione'"; $pippo = mysql_query ($sicontr); $sql5 = mysql_fetch_row ($pippo); if ($sql5[8] >= $sql5[7]) { $sql3 = "UPDATE treni_soppressione SET annunciata = 'si' WHERE giorno = '$giorno' AND mese = '$mese' AND anno = '$anno' AND orario = '$orario' AND direzione = '$direzione' "; $result3 = mysql_query($sql3); } else { $sql6 ="UPDATE treni_soppressione SET annunciata = 'no' WHERE giorno = '$giorno' AND mese = '$mese' AND anno = '$anno' AND orario = '$orario' AND direzione = '$direzione' "; $result4 = mysql_query($sql6); } } else { echo "Hai appena inserito una segnalazione per quel treno."; exit(); } } echo "<span style='font-family: arial';>grazie per la segnalazione</span></br>"; echo "<span style='font-family: arial';><a href='http://segratrain.altervista.org/'>torna alla pagina principale</a></span>"; ?> [ /code] Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/#findComment-685583 Share on other sites More sharing options...
Yesideez Posted November 8, 2008 Share Posted November 8, 2008 That's it although you've got [ /code] at the end inside the code box Check my previous reply for the tip... Link to comment https://forums.phpfreaks.com/topic/131685-how-and-where-put-the-captcha/#findComment-685586 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.