tpsilver10 Posted May 4, 2007 Share Posted May 4, 2007 Hey there... I'm trying to implement a CAPTCHA verification thing into my form, but with no success as yet. Basically, the issue is that the form appears to have been sent whether the security code is right or wrong, but the e-mail isn't actually sent (again, whether or not the code is right). I've tried a few different methods, but none seem to work so far. I'd be very appreciative if someone could take a look. I've attached a file with the pages in it. The files uploaded aren't actually trying to send an e-mail, just displaying whether the code was right or not. Thanks! [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/50003-form-with-captcha/ Share on other sites More sharing options...
tpsilver10 Posted May 4, 2007 Author Share Posted May 4, 2007 Maybe it'd be better to just post the code... <?php session_start(); include("global.inc.php"); $errors=0; $error="The following errors occured while processing your form input.<ul>"; pt_register('POST','name'); pt_register('POST','email'); pt_register('POST','address'); pt_register('POST','city'); pt_register('POST','postalcode'); pt_register('POST','province'); pt_register('POST','country'); pt_register('POST','phone'); pt_register('POST','fax'); pt_register('POST','adults'); pt_register('POST','youths'); pt_register('POST','children'); pt_register('POST','infants'); pt_register('POST','purpose'); pt_register('POST','from'); pt_register('POST','to'); pt_register('POST','departure'); pt_register('POST','return'); pt_register('POST','flexibility'); pt_register('POST','typeflight'); pt_register('POST','classflight'); pt_register('POST','accomodation'); pt_register('POST','room'); pt_register('POST','southaf'); pt_register('POST','namibia'); pt_register('POST','zimbabwe'); pt_register('POST','swaziland'); pt_register('POST','tunisia'); pt_register('POST','seychelles'); pt_register('POST','kenya'); pt_register('POST','botswana'); pt_register('POST','morocco'); pt_register('POST','tanzania'); pt_register('POST','zambia'); pt_register('POST','egypt'); pt_register('POST','mauritius'); pt_register('POST','citystopover'); pt_register('POST','gamelodges'); pt_register('POST','islandresort'); pt_register('POST','trekking'); pt_register('POST','rail'); pt_register('POST','smallgroup'); pt_register('POST','selfdrive'); pt_register('POST','fullyescorted'); pt_register('POST','cruises'); pt_register('POST','safaritours'); pt_register('POST','adventure'); pt_register('POST','other'); pt_register('POST','africaexperts'); pt_register('POST','acaciaafrica'); pt_register('POST','globetrotting'); pt_register('POST','otherdetails'); $otherdetails=preg_replace("/(\015\012)|(\015)|(\012)/"," <br />", $otherdetails);pt_register('POST','budget'); pt_register('POST','hearabout'); pt_register('POST','hearother'); pt_register('POST','title'); if($name=="" || $email=="" || $address=="" || $city=="" || $postalcode=="" || $province=="" || $country=="" || $phone=="" || $departure=="" || $return=="" || $title=="" ){ $errors=1; $error.="<li>You did not enter one or more of the required fields. Please go back and try again."; } if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email)){ $error.="<li>Invalid email address entered"; $errors=1; } if($errors==1) echo $error; else{ $where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/")); $message="name: ".$name." email: ".$email." address: ".$address." city: ".$city." postalcode: ".$postalcode." province: ".$province." country: ".$country." phone: ".$phone." fax: ".$fax." adults: ".$adults." youths: ".$youths." children: ".$children." infants: ".$infants." purpose: ".$purpose." from: ".$from." to: ".$to." departure: ".$departure." return: ".$return." flexibility: ".$flexibility." typeflight: ".$typeflight." classflight: ".$classflight." accomodation: ".$accomodation." room: ".$room." southaf: ".$southaf." namibia: ".$namibia." zimbabwe: ".$zimbabwe." swaziland: ".$swaziland." tunisia: ".$tunisia." seychelles: ".$seychelles." kenya: ".$kenya." botswana: ".$botswana." morocco: ".$morocco." tanzania: ".$tanzania." zambia: ".$zambia." egypt: ".$egypt." mauritius: ".$mauritius." citystopover: ".$citystopover." gamelodges: ".$gamelodges." islandresort: ".$islandresort." trekking: ".$trekking." rail: ".$rail." smallgroup: ".$smallgroup." selfdrive: ".$selfdrive." fullyescorted: ".$fullyescorted." cruises: ".$cruises." safaritours: ".$safaritours." adventure: ".$adventure." other: ".$other." africaexperts: ".$africaexperts." acaciaafrica: ".$acaciaafrica." globetrotting: ".$globetrotting." otherdetails: ".$otherdetails." budget: ".$budget." hearabout: ".$hearabout." hearother: ".$hearother." title: ".$title." "; $message = stripslashes($message); if (@$_COOKIE['tntcon']==md5(@$_POST['security_code']).'a4xn') { $result="<strong>CORRECT</strong> code entered"; } else { $result="<strong>WRONG</strong> code entered"; } ?> <!-- This is the content of the Thank you page, be careful while changing it --> <h2>Thank you!</h2> <table width=50%> <tr><td>name: </td><td> <?php echo $name; ?> </td></tr> <tr><td>email: </td><td> <?php echo $email; ?> </td></tr> <tr><td>address: </td><td> <?php echo $address; ?> </td></tr> <tr><td>city: </td><td> <?php echo $city; ?> </td></tr> <tr><td>postalcode: </td><td> <?php echo $postalcode; ?> </td></tr> <tr><td>province: </td><td> <?php echo $province; ?> </td></tr> <tr><td>country: </td><td> <?php echo $country; ?> </td></tr> <tr><td>phone: </td><td> <?php echo $phone; ?> </td></tr> <tr><td>fax: </td><td> <?php echo $fax; ?> </td></tr> <tr><td>adults: </td><td> <?php echo $adults; ?> </td></tr> <tr><td>youths: </td><td> <?php echo $youths; ?> </td></tr> <tr><td>children: </td><td> <?php echo $children; ?> </td></tr> <tr><td>infants: </td><td> <?php echo $infants; ?> </td></tr> <tr><td>purpose: </td><td> <?php echo $purpose; ?> </td></tr> <tr><td>from: </td><td> <?php echo $from; ?> </td></tr> <tr><td>to: </td><td> <?php echo $to; ?> </td></tr> <tr><td>departure: </td><td> <?php echo $departure; ?> </td></tr> <tr><td>return: </td><td> <?php echo $return; ?> </td></tr> <tr><td>flexibility: </td><td> <?php echo $flexibility; ?> </td></tr> <tr><td>typeflight: </td><td> <?php echo $typeflight; ?> </td></tr> <tr><td>classflight: </td><td> <?php echo $classflight; ?> </td></tr> <tr><td>accomodation: </td><td> <?php echo $accomodation; ?> </td></tr> <tr><td>room: </td><td> <?php echo $room; ?> </td></tr> <tr><td>southaf: </td><td> <?php echo $southaf; ?> </td></tr> <tr><td>namibia: </td><td> <?php echo $namibia; ?> </td></tr> <tr><td>zimbabwe: </td><td> <?php echo $zimbabwe; ?> </td></tr> <tr><td>swaziland: </td><td> <?php echo $swaziland; ?> </td></tr> <tr><td>tunisia: </td><td> <?php echo $tunisia; ?> </td></tr> <tr><td>seychelles: </td><td> <?php echo $seychelles; ?> </td></tr> <tr><td>kenya: </td><td> <?php echo $kenya; ?> </td></tr> <tr><td>botswana: </td><td> <?php echo $botswana; ?> </td></tr> <tr><td>morocco: </td><td> <?php echo $morocco; ?> </td></tr> <tr><td>tanzania: </td><td> <?php echo $tanzania; ?> </td></tr> <tr><td>zambia: </td><td> <?php echo $zambia; ?> </td></tr> <tr><td>egypt: </td><td> <?php echo $egypt; ?> </td></tr> <tr><td>mauritius: </td><td> <?php echo $mauritius; ?> </td></tr> <tr><td>citystopover: </td><td> <?php echo $citystopover; ?> </td></tr> <tr><td>gamelodges: </td><td> <?php echo $gamelodges; ?> </td></tr> <tr><td>islandresort: </td><td> <?php echo $islandresort; ?> </td></tr> <tr><td>trekking: </td><td> <?php echo $trekking; ?> </td></tr> <tr><td>rail: </td><td> <?php echo $rail; ?> </td></tr> <tr><td>smallgroup: </td><td> <?php echo $smallgroup; ?> </td></tr> <tr><td>selfdrive: </td><td> <?php echo $selfdrive; ?> </td></tr> <tr><td>fullyescorted: </td><td> <?php echo $fullyescorted; ?> </td></tr> <tr><td>cruises: </td><td> <?php echo $cruises; ?> </td></tr> <tr><td>safaritours: </td><td> <?php echo $safaritours; ?> </td></tr> <tr><td>adventure: </td><td> <?php echo $adventure; ?> </td></tr> <tr><td>other: </td><td> <?php echo $other; ?> </td></tr> <tr><td>africaexperts: </td><td> <?php echo $africaexperts; ?> </td></tr> <tr><td>acaciaafrica: </td><td> <?php echo $acaciaafrica; ?> </td></tr> <tr><td>globetrotting: </td><td> <?php echo $globetrotting; ?> </td></tr> <tr><td>otherdetails: </td><td> <?php echo $otherdetails; ?> </td></tr> <tr><td>budget: </td><td> <?php echo $budget; ?> </td></tr> <tr><td>hearabout: </td><td> <?php echo $hearabout; ?> </td></tr> <tr><td>hearother: </td><td> <?php echo $hearother; ?> </td></tr> <tr><td>title: </td><td> <?php echo $title; ?> </td></tr> <tr><td>nothing: </td><td> <?php echo $nothing; ?> </td></tr> <tr><td>nothing2: </td><td> <?php echo $nothing2; ?> </td></tr> <tr><td>nothing3: </td><td> <?php echo $nothing3; ?> </td></tr> <tr><td>nothing4: </td><td> <?php echo $nothing4; ?> </td></tr> </table> <!-- Do not change anything below this line --> <?php } ?> <?php header('Content-type: image/jpeg'); $width = 50; $height = 24; $my_image = imagecreatetruecolor($width, $height); imagefill($my_image, 0, 0, 0xFFFFFF); // add noise for ($c = 0; $c < 40; $c++){ $x = rand(0,$width-1); $y = rand(0,$height-1); imagesetpixel($my_image, $x, $y, 0x000000); } $x = rand(1,10); $y = rand(1,10); $rand_string = rand(1000,9999); imagestring($my_image, 5, $x, $y, $rand_string, 0x000000); setcookie('tntcon',(md5($rand_string).'a4xn')); imagejpeg($my_image); imagedestroy($my_image); ?> Link to comment https://forums.phpfreaks.com/topic/50003-form-with-captcha/#findComment-245496 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.