Home N-13 News Forums Help Search
RegisterForgot password?
How to add image to post necklacesdiscou
Known bugs - 4.0.3 necklacesdiscou

Latest N-13 News 4.0.3

What is N-13 News?
Where can I get help?
Known bugs

Forums Help & Support About CAPTCHA Code
1 2
Pretorian
Posted on 01 Jun 2008, 19:05:16

Access: Member
Total Posts: 17
Joined: 2008-05-29

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
#227
Last edited by Pretorian at 2008-06-01 19:05:38 Reason:
Chris
Posted on 01 Jun 2008, 19:28:51

Access: Admin
Total Posts: 1395
Joined: 2006-05-19

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.
#228
Pretorian
Posted on 01 Jun 2008, 19:45:59

Access: Member
Total Posts: 17
Joined: 2008-05-29

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
#229
Chris
Posted on 01 Jun 2008, 19:49:42

Access: Admin
Total Posts: 1395
Joined: 2006-05-19

doing the same thing with the guestmessages file is slightly easier

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.
#230
Pretorian
Posted on 01 Jun 2008, 20:01:55

Access: Member
Total Posts: 17
Joined: 2008-05-29

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?
#231
Last edited by Pretorian at 2008-06-01 20:05:06 Reason:
Chris
Posted on 01 Jun 2008, 20:03:59

Access: Admin
Total Posts: 1395
Joined: 2006-05-19

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.
#232
Pretorian
Posted on 01 Jun 2008, 20:16:17

Access: Member
Total Posts: 17
Joined: 2008-05-29

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
#233
Chris
Posted on 01 Jun 2008, 23:54:22

Access: Admin
Total Posts: 1395
Joined: 2006-05-19

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

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";
    }    
}
?>
#236
Pretorian
Posted on 02 Jun 2008, 20:01:10

Access: Member
Total Posts: 17
Joined: 2008-05-29

I Updated the code and now it's working perfectly
Thanks Chris...
#239
Mao
Posted on 17 Sep 2008, 19:09:57

Access: Member
Total Posts: 1
Joined: 2008-09-17

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.
#416
1 2
Network-13.com © 2013