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 How To Adding a security image to the comments form
1 2
Chris
Posted on 15 Oct 2009, 19:36:47

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

2 things you need to do to get this working. First is goto Options > System > Use image verification on comments form: Yes

Now you just need to add the security image to your template. Edit the template you're currently using and expand the Comments Form section. Now paste this code wherever you want the security image field to appear.

Code:
<div style="width: 100px; float: left">Security key:</div><input type="text" name="skey" id="skey" size="5" /> <img id="skeyimage" src="http://dev.network-13.com/news/image.php" title="Security key" /><br />


Be sure to change the path of the img src to your own path. There is also a new security image called imagenew.php which you can use instead, this is bigger and has colors.

Update
In version 3.5 reCAPTCHA has been integrated into the system. To enable it on the comments all you need to do is add the {recaptcha} tag wherever you want it to be displayed on the comments form then change the system setting Options > System > Use image verification on comments form: reCAPTCHA
#975
Last edited by Chris at 2010-04-02 03:18:45 Reason: added recaptcha
Mattycat
Posted on 22 Oct 2009, 02:36:48

Access: Member
Total Posts: 42
Joined: 2008-06-25

Can I use this captcha system on any other forms on my website? If so, how can I do this?
#1089
Chris
Posted on 22 Oct 2009, 02:39:12

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

I'll make you a quick example to show you how to do this. Watch this space.
#1090
Chris
Posted on 22 Oct 2009, 02:50:44

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

This should help you out.

Code:
<?php
session_name
('n13news');
session_start();

include_once 
'db.php';
include_once 
'config.php';

function 
showform(){
    echo 
"<form method=\"post\" action=\"\" />";
    echo 
"Captcha: <input type=\"text\" name=\"captcha\" /> <img src=\"imagenew.php\" /> ";
    echo 
"<input type=\"submit\" name=\"submitbutton\" value=\"Submit\" />";
    echo 
"</form>";
}
if(!
$_POST['submitbutton']){
    
//if the form hasn't been submitted show it.
    
showform();
}else{
    
//now we check if the captcha entered matches the image    
    
$captcha = $_POST['captcha']; //grab the text the user entered
    
$captcha = md5($salt . $captcha); //salt and md5 it
    
if($captcha == $_SESSION['image_random_value']){
        
//clear image_random_value to stop the user submitting the form multiple times by F5'ing
        
unset($_SESSION['image_random_value']);
        
        echo 
"success";
        
//the captcha is correct, do whatever you want here
    
}else{
        
//capcha is wrong, show form again with an error message
        
echo "Wrong captcha <br />";
        
showform();
    }
}
?>
#1091
Mattycat
Posted on 22 Oct 2009, 02:58:02

Access: Member
Total Posts: 42
Joined: 2008-06-25

How can I use this though? I'm putting the form on the page as part of a temple for my contact page.
#1092
Chris
Posted on 22 Oct 2009, 02:58:56

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

I've provided the code to show you how to make a custom form using the captcha, up to you to integrate your own form into it.
#1093
Mattycat
Posted on 22 Oct 2009, 03:14:45

Access: Member
Total Posts: 42
Joined: 2008-06-25

I added the code to the template I made - but nothing is showing up.

http://www.mjd.co.nz/contact.php
#1094
Chris
Posted on 22 Oct 2009, 03:21:55

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

Some knowledge of PHP is require if you want this to work, or get someone else who knows to do it for you.
#1095
Mathewklock
Posted on 04 Jan 2010, 04:36:35

Access: Member
Total Posts: 6
Joined: 2009-09-15

Hi,

I tried this, but the php file located at the dev.network-13 addy isn't working.

Mat
#1435
Chris
Posted on 04 Jan 2010, 08:05:17

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

You just need to change the location from dev.network-13.com to your own url.
#1437
1 2
Network-13.com © 2013