Well i need some help in there for my first cakephp tasks.
For a community website i am working on, i have a login form included
in views on top of all pages as an element.Then i have a specific page
wich you all know, the register page for adding new members to Mysql
Database ("Users" table). In that specific page i have an issue to
make both of forms working. Well i tried my auth component with the
login form it just worked fine, but when creating register page i
found out some problems on informing database of sent data.
Well here is my code if you can help some :
in Login form element called from layout view:
echo $form->create('User', array('url' => array('controller' =>
'users', 'action' => 'login')));
echo $form->input('username',array('class'=>'inputs2'));
echo $form->input('password',array('class'=>'inputs2'));
echo $form->submit('Login',array('class'=>'submits'));
echo $form->end();
in register.ctp :
echo $form->create('User', array('url' => array('controller' =>
'users', 'action' => 'register')));
echo $form->input('type_user',array('class'=>'inputs2'));
echo $form->input('username',array('class'=>'inputs2'));
echo $form->input('password',array('class'=>'inputs2'));
echo $form->input('password_confirm',array('class'=>'inputs2'));
echo $form->input('email',array('class'=>'inputs2'));
echo $form->submit('Register',array('class'=>'submits'));
echo $form->end();
my register action on users controller :
function register() {
if (!empty($this->data)) {
if ($this->data['User']['password'] == $this->data['User']
['password_confirm']) {
$this->User->query("INSERT INTO users
(id,username,password,email,type_user) VALUES ('','".$this->data
['username']."','".$this->data['password']."','".$this->data
['email']."','".$this->data['type_user']."')");
$this->render();
}
}
}
On 22 sep, 07:12, John Andersen <j.andersen...@gmail.com> wrote:
> Yes, you can't use twoforms, if you want both the title and the
> textarea to be submitted at the same time. In that case you only need
> one form.
>
> If you want to update either of them independently of each other, then
> you can use twoforms, or use two submit buttons, each named
> differently and processed accordingly in the controller.
>
> In any case, your form is not correct in your code, you are missing
> the echo $form->end();
>
> Enjoy,
> John
>
> On Sep 22, 1:30 am, ramanujan <dueago...@gmail.com> wrote:
>
> > Hi all. I'm new to cake and I'm trying to make a simple blog with a
> > private adminstrative section for adding posts and some other stuff,
> > and a public one which display post, let visitors add comments, search
> > posts etc.
>
> > Well my problem is that I decided to add a static page (about page) in
> > the pages view folder and make its contents editable in the
> > administrative section. So I decided to make an administrative page in
> > which one can set the blog title and edit this about page via two
> >forms.
>
> > Well bothformsare not binded with any model and a call a diffent
> > action but the first form works, i.e. the action get called and data
> > passed to it, while the second one, which contains a textarea to edit
> > the about's content, doesn't, i.e. the action doesn't even get called.
>
> > Is there any issue having twoformsin the same view?
>
> > Thisi is my code:
> [snip]
> > Note: admin_general is the administrataive page
>
> > admin_general.ctp:
> > <div class="index">
> > <div id="informazioni">
> > <div class="intestazione">
> > <h2>Titolo del blog</h2>
> > <?php
> > echo $form->create(false,array
> > ("action"=>"admin_blogTitle",'id'=>'formTitolo'));
> > ?>
> > <div class="fields">
> > <div class="input text">
> > <?php
> > echo $form->text('formTitolo.titolo',array
> > ("value"=>Configure::read('BLOG_TITLE')));
> > ?>
> > </div>
> > <?php
> > echo $form->submit('Applica');
> > ?>
> > </div>
> > </div>
> > <div id="editAbout">
> > <?php
> > echo $form->create(false,array
> > ("controller"=>"my_pages","action"=>"admin_about",'id'=>'formAbout'));
> > echo $form->input('formAbout.about',array
> > ('type'=>'textarea','label'=>'Descrizione del blog',
> > 'rows'=>15,"value"=>$about));
> > echo $form->submit('Salva modifiche');
> > ?>
> > </div>
> > </div>
> > </div>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment