View previous topic :: View next topic |
Author |
Message |
pstamb Smarty Rookie
Joined: 29 Jan 2007 Posts: 7
|
Posted: Tue Aug 28, 2007 10:09 am Post subject: |
|
|
Your need the GD library to be installed in PHP. Have a look at
http://gr2.php.net/manual/en/ref.image.php
Read the Requirements and Installation sections.
Greetings |
|
Back to top |
|
fallenOne Smarty n00b
Joined: 28 Aug 2007 Posts: 2
|
Posted: Wed Aug 29, 2007 3:51 am Post subject: |
|
|
That solves my problem...
Thank you so much....
|
|
Back to top |
|
waro Smarty Regular
Joined: 12 Jun 2008 Posts: 38
|
Posted: Fri Aug 01, 2008 12:27 am Post subject: Notice: Undefined index: |
|
|
I'm learning to use Smarty Captcha from smarty plug-ins site. It works fine but
some annoying notice message appear and I can't find the solution for them.
Here's my code: Code: | <?php
define ('CAPTCHA_SALT', 'gloryglorymanunited');
error_reporting(0);
require($_SERVER['DOCUMENT_ROOT'].'/devel/libs/smarty/Smarty.class.php');
$smarty =& new Smarty;
if (isset($_POST['name'])) {
include 'validate.php';
if (validate_captcha($_POST['captcha'],$_POST['code'])) {
$smarty->assign('result',1);
$smarty->assign('name',$_POST['name']);
$smarty->assign('comment',$_POST['comment']);
} else {
$smarty->assign('noresult',1);
}
}
$smarty->display('kapca2.tpl');
?> |
And here's the template: Code: | <html>
<head>
<title>Tes captcha</title>
</head>
<body>
<h1>Tes captcha</h1>
{if $result eq 1}
Nama: {$name}<br>
Comment: {$comment}<br>
<em>Captcha successfull!</em>
{elseif $noresult eq 1}
Captcha unsuccessfull!
{else}
<form method="POST" action="kapca2.php">
Name:<br /><input type="text" name="name" id="name" /><br />
Comment:<br /><textarea name="comment" id="comment" rows="6" cols="16"></textarea><br />
{captcha name="captcha" length=4}<br />
Insert code:<br />
<input type="text" name="code" id="code" /><br />
<input type="submit" value="Submit" />
</form>
{/if}
</body>
</html> |
You see that I tried to supressed error_reporting, but the notice reporting
still appear when I visited that script. The errors will disappear after
I input the form.
Code: | Notice: Undefined index: result in D:\xampplite\htdocs\tes\smarty\templates_c\%%F7^F7F^F7FCBEE3%%kapca2.tpl.php on line 11
Notice: Undefined index: noresult in D:\xampplite\htdocs\tes\smarty\templates_c\%%F7^F7F^F7FCBEE3%%kapca2.tpl.php on line 17 |
The line error point to undefined variable, but I use this technique in the
past successfully. I tried to use Variable Modifiers such as 'default' (e.g: {$result|default|escape}), but the notice report still exists.
Would anyone help me? |
|
Back to top |
|
Celeb Administrator
Joined: 17 Apr 2007 Posts: 1025 Location: Vienna
|
Posted: Mon Aug 04, 2008 12:29 pm Post subject: |
|
|
Try setting
Code: | $smarty->error_reporting = E_ALL ^ E_NOTICE; |
_________________ Darn computers always do what I tell them to instead of what I want them to do. |
|
Back to top |
|
waro Smarty Regular
Joined: 12 Jun 2008 Posts: 38
|
Posted: Sun Aug 10, 2008 2:37 pm Post subject: |
|
|
It didn't work, but when I read the manual, I found a function called
isset, which I didn't know it exists in Smarty, and change my template to:
Code: |
{if isset($result)}
Nama: {$name}<br>
Comment: {$comment}<br>
Captcha's successful!
{elseif isset($noresult)}
Captcha's unsuccessful!
|
And the notice messages is vanished.
And that's why people keep writing RTFM!!! Shame on me.
Last edited by waro on Wed Aug 20, 2008 11:57 pm; edited 3 times in total |
|
Back to top |
|
Celeb Administrator
Joined: 17 Apr 2007 Posts: 1025 Location: Vienna
|
Posted: Mon Aug 11, 2008 2:22 pm Post subject: |
|
|
isset() is a standard PHP function. You can use any PHP functions inside {if} aslong as security is off or the function is in the IF_FUNCS array of $security_settings. And now guess if that's stated in the manual _________________ Darn computers always do what I tell them to instead of what I want them to do. |
|
Back to top |
|
bjarman Smarty n00b
Joined: 14 Aug 2008 Posts: 1
|
Posted: Thu Aug 14, 2008 7:28 am Post subject: Blank page |
|
|
Hi!
I have installed everything regarding the captcha plugin according to the instructions.txt but as soon as i put {captcha [name="captcha"] [length=4]} in any of my templates it results in a blank page.
I read that someone had this problem before me but the solution, if any, was never posted back here.
Has anyone experienced this and solved it, plese post solution or suggestions. |
|
Back to top |
|
Celeb Administrator
Joined: 17 Apr 2007 Posts: 1025 Location: Vienna
|
Posted: Thu Aug 14, 2008 3:15 pm Post subject: |
|
|
Start with setting error_reporting to E_ALL when you're getting blank pages.
Are you actually using the [ ] parentheses? They don't belong there, it should read just
Code: | {captcha name=captcha lenght=4} |
_________________ Darn computers always do what I tell them to instead of what I want them to do. |
|
Back to top |
|
waro Smarty Regular
Joined: 12 Jun 2008 Posts: 38
|
Posted: Wed Aug 20, 2008 11:57 pm Post subject: |
|
|
just a note:
in function.captcha.php, error reporting sets to E_ALL, you maybe want to change this to prevent error message that bug me for a few days. |
|
Back to top |
|
navid_gh Smarty Rookie
Joined: 16 Oct 2008 Posts: 6
|
Posted: Thu Oct 16, 2008 9:54 am Post subject: |
|
|
why use php captcha class? |
|
Back to top |
|
ucntkilme Smarty Regular
Joined: 03 Sep 2007 Posts: 84
|
Posted: Wed Nov 05, 2008 8:36 pm Post subject: |
|
|
Okay so here is a weird thing that may not be possible...
I've just finished a website for a client, and their contact form is being spammed like nuts (at least 30 a minute)...
So I wanted to add in a captcha, and I had already downloaded this plugin for use with my site when I reprogram it, but have yet to actually use it...
in my index.php here is my code:
Code: |
<?php
session_start();
define('SMARTY_DIR', 'inc/libs/');
define ('CAPTCHA_SALT', 'rvwebhostingdotcom');
require_once('inc/aws.php');
require ('inc/libs/SmartyPaginate.class.php');
$aws =& new AWS; // create the object
?>
|
Now that looks to me like it is right or whatever I dunno... BUT for this website, the contact form is not in a tpl file, it is stored in the database...
Is that possible to do or should I move my page out of the database and into a tpl file? |
|
Back to top |
|
Celeb Administrator
Joined: 17 Apr 2007 Posts: 1025 Location: Vienna
|
|
Back to top |
|
manfred Smarty Rookie
Joined: 07 Oct 2008 Posts: 10
|
Posted: Wed Nov 26, 2008 6:27 pm Post subject: |
|
|
Thank you for your Great plug in
me new to the smarty world
how we validate it with your validate.php
Code: |
function validate_captcha($md5, $code){
$shouldbe = md5($code . CAPTCHA_SALT . 'some salt' . $code .CAPTCHA_SALT . 'extra salt');
return ($shouldbe == $md5);
} |
My template is like this
Code: | <td>{captcha name="captcha" length=6}</td>
<td><input type="text" name="captcha" /></td>
|
thanks |
|
Back to top |
|
mariorui Smarty n00b
Joined: 31 May 2013 Posts: 1
|
Posted: Fri May 31, 2013 4:19 pm Post subject: Re: Blank page |
|
|
Hi all,
i'm having a problem with this plugin. It was working fine 'till a few days ago, but now, where should appear the captcha image, the code is truncated ' till the end of page...
I havenīt made any changes and i don't understand what happened. Can anyone give me a clue?
Thanks in advance. |
|
Back to top |
|
|