Login

Member statsTotal: 206Latest: CcardinGuests online: 7Members online: 0
EmailLogin here

Location
ForumHelp & Support • About CAPTCHA Code

Access: Member
Total posts: 17

Status: Offline
About CAPTCHA Code Quote 

Chris, How can i integrate a captcha code in the script (for comments).
Can you describe and demonstrate how to do this... CAPTCHA Code like in this forum?

Thank You
02:05pm 1st Jun 08  
Last edited by Pretorian at 02:05pm 1st Jun 08
Access: Admin
Total posts: 174

Status: Offline
Re: About CAPTCHA Code Quote 

Ok this will be a bit tricky, first off open this file http://network-13.com/newindex.txt, replace everything inside your own index.php file with that, then make any changes that you'd previously made.

Second thing you need to do is edit the Template you are currently using and add a new field to the comment form

Code:
<div style="width: 100px; float: left">&nbsp;</div><input type="text" size="4" id="key" name="key" /> Type this code <img src="image.php" />

This will add a new box for the user to enter the security key, and will display the key beside it.

Once thats done it should 'hopefully' work.
02:28pm 1st Jun 08
_______________
Chris - Network-13
Access: Member
Total posts: 17

Status: Offline
Re: About CAPTCHA Code Quote 

Waw Cool Chris... Thank you very much, but what about the guestmessage.php
Please integrate there too, it really needs the CAPTCHA Security, You know today there're many robots searching for mail forms for spamming

Thank You Chris
02:45pm 1st Jun 08  
Access: Admin
Total posts: 174

Status: Offline
Re: About CAPTCHA Code Quote 

doing the same thing with the guestmessages file is slightly easier

PHP Code:
<?php
include 'db.php';
include
'config.php';
$sendto = 'Chris'; #put your username here
function showguestform(){
?>
<form method="post" action="">
Name: <input type="text" name="guestname" value="<?php echo htmlentities($_POST['guestname']); ?>" /><br />
Email: <input type="text" name="guestemail" value="<?php echo htmlentities($_POST['guestemail']); ?>" /><br />
Message: <textarea name="guestmessage"><?php echo htmlentities($_POST['guestmessage']); ?></textarea><br />
Security key: <input type="text" id="key" name="key"><img src="news/image.php" /><br />
<input type="submit" name="guests1" value="Send message" />
</form>
<?php

}

if(!
$_POST['guests1']){
    
showguestform();
}else{
    if(
md5($_POST['key'] !== $_SESSION['image_random_value'])){
        echo
"Please enter the security key<br />";
        
showguestform();
    }elseif(!
$_POST['guestname']){
        echo
"Please enter your name<br />";
        
showguestform();
    }elseif(!
$_POST['guestemail']){
        echo
"Please enter your email address<br />";
        
showguestform();
    }elseif(!
$_POST['guestmessage']){
        echo
"Please enter a message<br />";
        
showguestform();
    }else{
        
$guestid = getresult("SELECT uid FROM $newsusers WHERE user = 'Guest'");
        
$title = "New message from " . slash2($_POST['guestname']);
        
$message = "Email address: " . slash2($_POST['guestemail']) . "\n\r\n\r" . slash2($_POST['guestmessage']);
        
$sentfrom = $guestid;
        
$sentto = getresult("SELECT uid FROM $newsusers WHERE user = '$sendto'");
        
$viewed = 1;
        
$posted = time();
        
$sql = "INSERT INTO $newsprivate (title,message,sentfrom,sentto,viewed,posted) VALUES ('$title','$message','$sentfrom','$sentto','$viewed','$posted')";
        
$query = mysql_query($sql) or die(mysql_error());
        
        echo
"Your message has been sent";
    }    
}
?>


I didn't test this I just wrote it up quickly, as far as I can see it looks fine though.
02:49pm 1st Jun 08
_______________
Chris - Network-13
Access: Member
Total posts: 17

Status: Offline
Re: About CAPTCHA Code Quote 

I Updated the Guestmessage.php, but there is no image displayed. I checked the property of the image border and it was targeted to image.php, i don't remember that this script has file named as image.php

What do you think Chris

P.S. Is this because that i haven't updated index.php yet?
03:01pm 1st Jun 08  
Last edited by Pretorian at 03:05pm 1st Jun 08
Access: Admin
Total posts: 174

Status: Offline
Re: About CAPTCHA Code Quote 

In your news directory there should be a file called image.php, you should change the location of the <img> tag to point to that location.
03:03pm 1st Jun 08
_______________
Chris - Network-13
Access: Member
Total posts: 17

Status: Offline
Re: About CAPTCHA Code Quote 

Now Security Code can be seen, but it seems not working. Says That "Please enter the security key" but i entered it many times.....

Thank you very much Chris
03:16pm 1st Jun 08  
Access: Admin
Total posts: 174

Status: Offline
Re: About CAPTCHA Code Quote 

Ah that was my fault, I made a typo, use this code

PHP Code:
<?php
session_start
();
include
'db.php';
include
'config.php';
$sendto = 'Chris'; #put your username here
function showguestform(){
?>
<form method="post" action="">
Name: <input type="text" name="guestname" value="<?php echo htmlentities($_POST['guestname']); ?>" /><br />
Email: <input type="text" name="guestemail" value="<?php echo htmlentities($_POST['guestemail']); ?>" /><br />
Message: <textarea name="guestmessage"><?php echo htmlentities($_POST['guestmessage']); ?></textarea><br />
Security key: <input type="text" id="key" name="key"><img src="image.php" /><br />
<input type="submit" name="guests1" value="Send message" />
</form>
<?php

}

if(!
$_POST['guests1']){
    
showguestform();
}else{

    if(
md5($_POST['key']) !== $_SESSION['image_random_value']){
        echo
"Please enter the security key<br />";
        
showguestform();
    }elseif(!
$_POST['guestname']){
        echo
"Please enter your name<br />";
        
showguestform();
    }elseif(!
$_POST['guestemail']){
        echo
"Please enter your email address<br />";
        
showguestform();
    }elseif(!
$_POST['guestmessage']){
        echo
"Please enter a message<br />";
        
showguestform();
    }else{
        
$guestid = getresult("SELECT uid FROM $newsusers WHERE user = 'Guest'");
        
$title = "New message from " . slash2($_POST['guestname']);
        
$message = "Email address: " . slash2($_POST['guestemail']) . "\n\r\n\r" . slash2($_POST['guestmessage']);
        
$sentfrom = $guestid;
        
$sentto = getresult("SELECT uid FROM $newsusers WHERE user = '$sendto'");
        
$viewed = 1;
        
$posted = time();
        
$sql = "INSERT INTO $newsprivate (title,message,sentfrom,sentto,viewed,posted) VALUES ('$title','$message','$sentfrom','$sentto','$viewed','$posted')";
        
$query = mysql_query($sql) or die(mysql_error());
        
        echo
"Your message has been sent";
    }    
}
?>
06:54pm 1st Jun 08
_______________
Chris - Network-13
Access: Member
Total posts: 17

Status: Offline
Re: About CAPTCHA Code Quote 

I Updated the code and now it's working perfectly
Thanks Chris...
03:01pm 2nd Jun 08  
Access: Member
Total posts: 1

Status: Offline
About CAPTCHA Code Quote 

Hi! I'm Italian and I can't download this file. Can you post it again?
I can't install the captcha without it!

Thanks.
02:09pm 17th Sep 08  
Post a reply!

1 2 >