Here you have some code, i hope it works to you
--------------------------------------------------------------------------------------------------------------------
In the model ( colega.php )
--------------------------------------------------------------------------------------------------------------------
var $validate = array(
'usuario' => VALID_NOT_EMPTY, // Can't be empty
'password' => VALID_NOT_EMPTY,
'nombre' => VALID_NOT_EMPTY,
'email' => VALID_EMAIL, // Has to be a valid email
);
--------------------------------------------------------------------------------------------------------------------
In the view ( registrar.thtml )
--------------------------------------------------------------------------------------------------------------------
<form action="<?php echo $html->url('registrar'); ?>" method="post">
<table>
<tr>
<td valign="top">Username</td>
<td><?php echo $html->input('Colega/usuario', array()) ?><?php
echo $html->tagErrorMsg('Colega/usuario','Enter a Username') ?></td>
</tr>
<tr>
<td valign="top">Password</td>
<td><?php echo $html->password('Colega/password',array()) ?><?
php echo $html->tagErrorMsg('Colega/password','Enter a Password') ?></
td>
</tr>
<tr>
<td valign="top">Name</td>
<td><?php echo $html->input('Colega/nombre',array()) ?><?php
echo $html->tagErrorMsg('Colega/nombre','Enter a Name') ?></td>
</tr>
<tr>
<td valign="top">Email</td>
<td><?php echo $html->input('Colega/email',array()) ?><?php
echo $html->tagErrorMsg('Colega/email','Enter an Email') ?></td>
</tr>
<tr><td colspan="2" align="center"><?php echo $html-
>submit('Send') ?></td></tr>
</table>
</form>
--------------------------------------------------------------------------------------------------------------------
In the controller ( colegas_controller.php )
--------------------------------------------------------------------------------------------------------------------
function registrar()
{
if(!empty($this->data))
{
if($this->Colega->validates($this->data))
{
if($this->Colega->findByUsuario($this->data['Colega']
['usuario']))
{
$this->Colega->invalidate('usuario');
}
else
{
$this->Session->Write('rgusuario',$this->data['Colega']
['usuario']);
$this->Session->Write('rgpassword',$this->data['Colega']
['password']);
$this->Session->Write('rgnombre',$this->data['Colega']
['nombre']);
$this->Session->Write('rgemail',$this->data['Colega']
['email']);
$this->Session->Write('rgdcp',$this->data['Colega']['dcp']);
$this->redirect('/colegas/registrado');
}
}
else
{
if($this->Colega->findByUsuario($this->data['Colega']
['usuario']))
{
$this->Colega->invalidate('usuario');
}
}
}
}
function registrado()
{
if ($this->Session->read('rgusuario'))
{
$this->data['Colega']['id'] = '';
$this->data['Colega']['usuario'] = $this->Session-
>read('rgusuario');
$this->data['Colega']['password'] = $this->Session-
>read('rgpassword');
$this->data['Colega']['nombre'] = $this->Session-
>read('rgnombre');
$this->data['Colega']['email'] = $this->Session->read('rgemail');
$this->Colega->save($this->data);
$this->Session->Del('rgusuario');
$this->Session->Del('rgpassword');
$this->Session->Del('rgnombre');
$this->Session->Del('rgemail');
}
else
{
$this->redirect('/colegas/registrar');
}
}
Rohman
http://www.rohmansama.com
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---