Monday, October 11, 2010

Re: How to access Posted data

Thanks for the reply, i will do as you suggested.

On Mon, Oct 11, 2010 at 2:25 PM, Jeremy Burns | Class Outfit <jeremyburns@classoutfit.com> wrote:
A couple of things...

The users_controller will, by default, use the User model, so there is no need to declare it in the $uses array in the controller or to loadModel('User').

If you set up a relationship between the User model and the Comp model (why isn't that the Company model - why is your table called comps not companies?) then you can access it via the User model: $this->User->Company

You don't seem to be using the Auth component, which will handle user authentication for you.

I'd recommend that you walk through the early parts of the second tutorial (http://book.cakephp.org/view/1543/Simple-Acl-controlled-Application) which will help you through this.

On 11 Oct 2010, at 08:42, @gomesh wrote:

Hi everybody

I have 2 models (User,Comp) and 2 Controllers
(users_controller,comps_controller).Users & Comps table have no
relationship.They are independent of one another.Now i have a login
View where there are four things {1} Input box for Username, {2} Input
box for Password , {3} Select box for installed Company Names and {4}
a submit button.

Now, Login View is generated from login action in the
users_controllers.php::::>>

var $name='Users';
var $helpers = array('Html','Form');
var $uses = array('User','Comp'); /*--Name of the Model this
Controller uses--*/
function index()
{
$this->layout='default_admin';
}

function login()
{
/*--------Name of the layout it
uses----------------------------------bgn*/
$this->layout = 'default'; /*--Name of the layout it uses from the
directory app/views/layouts--*/
       /
*--------------------------------------------------------------------
end*/

/*--------*/
//Call Comp Model using loadModel()
$this->loadModel('Comp');
$cNames = $this->Comp->find('list',array('fields'=>
array('Comp.comp_name')));
//$cNames = $this->Comp->query("SELECT comps.comp_name FROM comps");
$this->set('compNames',$cNames);

//redirect user if already logged in
if ($this->Session->check('User'))
{
$this->redirect(array('action'=>'index'));
}

if (empty($this->data) == false)
       {
//set the form data to enable Input data validation
$this->User->set($this->data);
//see if the input data validates
if($this->User->validates())
{
//check the user is valid
$result = $this->User->check_user_data($this->data);
if($result !== false)
{
//save to session
$this->Session->write('User',$result); /*--'User' name of the
session--*/

//show message
//$this->Session->setFlash('You have successfully logged in');
//redirect to appropriate page
$this->redirect(array('action'=>'index'));
}
else
{
$this->Session->setFlash('Either your Username or Password is
incorrect');
}
}
       }
}

Username and Password are from User model but Company name is from
Comp model.Now i want to create a session variable and in there i want
to store the Company name selectd from the select box.Now, my problem
is how do i access the value of Select box in the controller so that i
could put it in a session variable under the following given
circumstances.Please advise

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
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

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate