Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7953957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:16:46+00:00 2026-06-04T03:16:46+00:00

im struggling with my cake code(very new to cakephp) and was after some help.

  • 0

im struggling with my cake code(very new to cakephp) and was after some help. what is intended by my code is to get data from a form and when the person hits register it send data to my database but that is not happening, instead when i hit register the page is reloading. I’m currently using cake 2.0 and wamp server 2.2

here is the code for my add function from my individualscontroller.php

function addIndividual(){
    if($this->request->is('individuals')){
    {if ($this->Individual->save($this->request->data)) {
            $this->Session->setFlash('The user has been saved');
            $this->redirect(array('action' => 'index'));
        } else {
$this->Session->setFlash('The user could not be saved. Please, try again.');
        }
    }
}

} code here

and here is the code from my add_individual.ctp including the form

   <h2>Please enter your details</h2>
<?php
echo $this->Form->create('individuals', array('action'=>'addIndividual'));
echo $this->Form->input('Title: ');
echo $this->Form->input('First Name: ');
echo $this->Form->input('Surname: ');
echo $this->Form->input('Street Address: ');
echo $this->Form->input('Suburb: ');
echo $this->Form->input('State: ');
echo $this->Form->input('Country: ');
echo $this->Form->input('Email: ');
echo $this->Form->input('Password: ');
echo $this->Form->end('Click here to Register');

?>

EDIT – The name of the table im trying to insert data into is called individuals
any help would be greatly appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:16:48+00:00Added an answer on June 4, 2026 at 3:16 am
    function addIndividual(){
    if($this->request->is('individuals')){
    if ($this->Individual->save($this->request->data)) {
            $this->Session->setFlash('The user has been saved');
            $this->redirect(array('action' => 'index'));
        } else {
    $this->Session->setFlash('The user could not be saved. Please, try again.');
        }
    }
    }
    

    Change this code to

    function addIndividual(){
    if($this->request->is('post')){
    {if ($this->Individual->save($this->request->data)) {
            $this->Session->setFlash('The user has been saved');
            $this->redirect(array('action' => 'index'));
        } else {
    $this->Session->setFlash('The user could not be saved. Please, try again.');
        }
    }
    }
    

    Also please change your view file as follows.

    <h2>Please enter your details</h2>
    <?php
    echo $this->Form->create('Individual', array('action'=>'addIndividual'));
    echo $this->Form->input('FieldnameasinDB',array('label'=>'Title: '));
    echo $this->Form->input('FieldnameasinDB',array('label'=>'First Name: '));
    echo $this->Form->input('FieldnameasinDB',array('label'=>'Surname: '));
    echo $this->Form->input('FieldnameasinDB',array('label'=>'Street Address: '));
    echo $this->Form->input('FieldnameasinDB',array('label'=>'Suburb: '));
    echo $this->Form->input('FieldnameasinDB',array('label'=>'State: '));
    echo $this->Form->input('FieldnameasinDB',array('label'=>'Country: '));
    echo $this->Form->input('FieldnameasinDB',array('label'=>'Email: '));
    echo $this->Form->input('FieldnameasinDB',array('label'=>'Password: '));
    echo $this->Form->end('Click here to Register');
    
    ?>
    

    Change the model like this

    <?php class Individual extends AppModel{ var $name='Individual'; 
        public $useTable = 'tableName';
        public $primaryKey = 'userid';} 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm struggling to implement ACL in CakePHP. After reading the documentation in the cake
Really struggling to figure this out. Just trying to take in data from php
Struggling to get my head around these MD Arrays so hoping someone can help.
After struggling for days attempting to get back collections that are linked to a
Really struggling to get to these route data values...When I type I just cant
Struggling with one aspect of my code that I hope someone could shed some
Attempting/struggling to get registration and sign-up working within an active admin project. I have
I'm sure this is a piece of cake but I'm really struggling with something
Struggling with this one. I have set up a basic email/enquiry form for a
Struggling with this tournament fixtures algorithm. The code is working perfectly but I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.