fullyloaded Posted July 15, 2012 Share Posted July 15, 2012 hi i was wondering if anyone can give me a hand adding this captcha script? i have tried everything i can think of with no luck at all. I think my problem has to do with the session where i already have one started but i could be wrong, any help would be great thanks. My code: <?php include("db.php"); $error_message=""; $email_to = mysql_real_escape_string(strip_tags($_POST['email_to'])); $today = date("M d, Y h:i A"); $ip = $_SERVER['REMOTE_ADDR']; if (isset($_POST['submit'])){ if($_SERVER['REQUEST_METHOD'] == 'POST') { if(!isset($_SESSION['csrf']) || $_SESSION['csrf'] !== $_POST['csrf']) $sql = "SELECT username FROM users WHERE mailaddress = '{$email_to}'"; $result=mysql_query($sql, $conn) or die('Error in query:<br>'. $sql .'<br>'.mysql_error($conn).'<br>Time of Error: '.date("l F j, Y, G:i:s T")); $count=mysql_num_rows($result); if($count==1){ $rows=mysql_fetch_array($result); $username=htmlentities($rows['username']); $to=$email_to; $subject="mysite Username reminder."; $header="from: noreply@mysite.com"; $messages= "Hey $username, \r\n"; $messages.=" \r\n"; $messages.="You recently request your mysite username on $today \r\n"; $messages.=" \r\n"; $messages.="Your username is: $username \r\n"; $messages.=" \r\n"; $messages.="You can sign in at: https://www.mysite.com \r\n"; $messages.=" \r\n"; $messages.="Your username was requested from the following ip address: $ip \r\n"; $messages.=" \r\n"; $messages.="Thanks, \r\n"; $messages.="From mysite.com \r\n"; $sentmail = mail($to,$subject,$messages,$header); } else { $error_message = 'Sorry email address not found.'; } if($sentmail){ $error_message = 'Your username has been sent to your email address.'; } else { $error_message = 'username was not sent please try again.'; } } } $key = sha1(microtime()); $_SESSION['csrf'] = $key; ?> Captcha code trying to add: <?php session_start(); if (md5($_POST['csrf']) == $_SESSION['csrf']){ $error_message = 'Captcha good.'; } else { $error_message = 'Captcha wrong.'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/265707-problem-adding-captcha-to-script/ Share on other sites More sharing options...
bleured27 Posted July 15, 2012 Share Posted July 15, 2012 there are loads of programms about how to add a capcha MAKING one is much WORK so i recoment to go at google serching a download. Quote Link to comment https://forums.phpfreaks.com/topic/265707-problem-adding-captcha-to-script/#findComment-1361684 Share on other sites More sharing options...
fullyloaded Posted July 15, 2012 Author Share Posted July 15, 2012 hi bleured27 thanks for the reply, i have search google and came up with a lot of scripts and have a captcha script. The code i posted (my captcha script) is the part im having problems adding to my script, i been watching tuts for 2 days and did learn a lot but still am having a problem with adding that bit of code. Quote Link to comment https://forums.phpfreaks.com/topic/265707-problem-adding-captcha-to-script/#findComment-1361685 Share on other sites More sharing options...
bleured27 Posted July 18, 2012 Share Posted July 18, 2012 are you dutch because i Know dutch help for you i translated it it will be a math question example 1+1 = [ input box ] <?php session_start(); require_once 'Numeral.php'; $numcap = new Text_CAPTCHA_Numeral; //your stuff if (isset($_POST['captcha']) && isset($_SESSION['answer'])) { if ($_POST['captcha'] == $_SESSION['answer']) { } else { $vervuild = TRUE; $melding .= "plz try captcha again "; } more tomorrow i go sleep Quote Link to comment https://forums.phpfreaks.com/topic/265707-problem-adding-captcha-to-script/#findComment-1362539 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.