Hello, I've been enjoying all the answers in this group and they have
helped me tremendously, but I've stumbled across something I can't
seem to fix myself. The objective was simple: make a registration for
Users where a password must be confirmed and a Captcha check is used
to verify it isn't spam. (I know blind people can't see them, but
there's an audio possiblity that will be elaborated once the chance
that a blind person visits the site is higher than 0.2, plus, it's a
client-demand).
Okay, so this doesn't seem like a very complicated thing to do, right?
I searched the bakery and found the page about PHP-Captcha, installed
it, removed the session-line like they said but I get an apache-error
still. The last entry when I hit submit in the apache error-log is:
[Tue Jul 10 12:27:36 2007] [error] PHP Warning: session_start():
Cannot send session cache limiter - headers already sent (output
started at d:\\program files\\easyphp1-8\\www\\vendors\\phpcaptcha\
\php-captcha.inc.php:331) in d:\\program files\\easyphp1-8\\www\\cake\
\libs\\session.php on line 154
[Tue Jul 10 12:27:36 2007] [error] PHP Warning: Cannot modify header
information - headers already sent by (output started at d:\\program
files\\easyphp1-8\\www\\vendors\\phpcaptcha\\php-captcha.inc.php:331)
in d:\\program files\\easyphp1-8\\www\\cake\\libs\\session.php on line
155
As you may see, I'm using easyphp for the moment, it will be deployed
on the real server when we get it. Oh, and my cake version is 1.1 as
1.2 crashes apache right from the beginning.
Relevant code:
<?php
uses('sanitize');
class UsersController extends AppController {
var $name = 'Users';
var $helpers = array('Html', 'Form' );
var $components = array ('Acl', 'Security', 'Session', 'Captcha');
function beforeFilter(){
$this->Security->requireAuth('delete', 'register');
}
....
function register($optional = false) {
$this->set('username_error', 'Username must be between 4 and 40
characters without spaces or special characters.');
$this->set('password_error', 'Password must be between 4 and 40
characters without spaces or special characters.');
if($optional == true){ $this->set('countries',
$this->User->Country-
>generateList()); }
$this->set('optional', $optional);
if (!empty($this->data)){
if ($this->User->validates($this->data)){
if
($this->User->findByUsername($this->data['User']['username'])){
$this->User->invalidate('username');
$this->set('username_error', 'User
already exists.');
} else if ($this->data['User']['password'] !=
$this->data['User']
['retype_password']){
$this->User->invalidate('password');
} else if
(!$this->Captcha->check($this->data['User']
['user_captcha'])){
} else {
$this->cleanUpFields();
$this->data['User']['password'] =
md5($this->data['User']
['password']);
if($this->User->save($this->data['User'])){
$aro = new Aro();
$aro->create($this->User->id,
'Users', $this->data['User']
['username']);
$this->Session->setFlash('Registration successful');
$this->redirect('/users/index');
} else {
$this->Session->setFlash('Registration unsuccessful, there was
an error saving to the database.');
$this->redirect('/users/index');
}
}
}
} else {
$this->render();
$this->validateErrors($this->User);
}
}
....
}
And the view:
<?php echo $html->formTag('/users/register') ?>
....
<div class="required">
<img id="captcha" src="<?php echo $html->url('/users/
captcha_image');?>" alt="" />
<a href="javascript:void(0);"
onclick="javascript:document.images.captcha.src='<?php echo $html-
>url('/users/captcha_image');?>?' +
Math.round(Math.random(0)*1000)+1">Reload image</a>
<?php echo $form->labelTag('User/user_captcha', 'Please retype the
text in the above image');?>
<?php echo $html->input('User/user_captcha', array('size' => '60'));?
>
</div>
....
</form>
When I remove the given code in the view and the line "} else if (!
$this->Captcha->check($this->data['User']['user_captcha'])){", then it
works normally. Now, when I hit submit apache crashes and burns with a
session error...
I'm sorry for my lengthy post, can anybody please help me?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---