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 7951671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:37:51+00:00 2026-06-04T02:37:51+00:00

I have a few different contact forms in my CakePHP 2.0 application. All of

  • 0

I have a few different contact forms in my CakePHP 2.0 application. All of the contact forms are emailing as they should, but I need this particular one to also save the form results to the database. The post data is populating, and I can print_r() and pr() the form data. I can even email the post data. However, it is not actually saving the data to the model table. The database table is named contacts and has the following fields: id, publication, company, name, email, phone, message, contact_method, selections, received.

Here is my model:

class Contact extends AppModel {
    public $name = 'Contact';

    public $useTable = 'contacts';

    public $validate = array(  
    'name' => array(
            'rule' => 'notEmpty'
        ),
        'email' => array(
            'rule' => 'notEmpty'
        )
    );

Here is my controller:

App::uses('CakeEmail', 'Network/Email');

class ContactsController extends AppController
{
    public $name = 'Contacts';
    public $helpers = array('Html', 'Form', 'Js');
    public $components = array('Email', 'Session');

...

    public function contact_att() {

        if ($this->request->is('post')) {

            //pr($this->data);
            if ($this->Contact->save($this->request->data)) {
                $this->redirect('/pages/publications-alabama-turf-times');
                $this->Session->setFlash("Mesage Saved!"); 
            }

            else {
                print_r($this->data);
                Configure::write('debug', 2); 
                debug($this->Contact->validationErrors); 

                exit;
            }
        }

Here is the form in my view:

echo $this->Form->create('Contact', array(
    'action' => 'contact_att', 
    'label' => '', 
    'class' => 'pubs'));
echo $this->Form->input('publication', array(
    'type' => 'hidden', 
    'value' => 'A', 
    'label' => ''));
echo $this->Form->input('company', array(
    'default' => 'company name (required)', 
    'onfocus' => 'clearDefault(this)', 
        'label' => array(
            'text' => 'Company Name',
            'style' => 'position:absolute;')));
echo $this->Form->input('name', array(
    'default' => 'name (required)', 
    'onfocus' => 'clearDefault(this)', 
    'label' => array(
        'text' => 'Your Name',
        'style' => 'position:absolute;')));
echo $this->Form->input('phone', array(
    'default' => 'phone number (required)', 
    'onfocus' => 'clearDefault(this)', 
    'label' => array(
        'text' => 'Your Phone Number',
        'style' => 'position:absolute;')));
echo $this->Form->input('email', array(
    'default' => 'email (required)', 
    'onfocus' => 'clearDefault(this)', 
    'label' => array(
        'text' => 'Your Email Address',
        'style' => 'position:absolute;')));
echo $this->Form->input('message', array(
    'label' => array(
        'text' => 'Your Message',
        'style' => 'position:absolute;')));
echo $this->Form->input('contact_method', array(
    'type' => 'radio',
    'style' => 'padding-right:20px;', 
    'legend' => 'Preferred contact method:', 
    'options' => array(
        'phone' => 'phone',
        'email' => 'email'
        )
    ));
echo $this->Form->input('selections', array(
    'type' => 'select', 
    'label' => array(
    'text' => 'I am interested in the following:', 
    'style' => 'display:block; width:250px; margin-left:-12px;padding-bottom:15px;'),
        'multiple' => 'checkbox',
        'options' => array(
            'ABC' => 'ABC', 
            'DEF' => 'DEF', 
            'GHI' => 'GHI'
         )
    ));

echo $this->Form->end('Submit');

What am I missing?

  • 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-04T02:37:53+00:00Added an answer on June 4, 2026 at 2:37 am

    After much banging my head on the desk, the answer turned out to be simple — of course. I simply removed this line from my model. I thought that having it set to the correct table would be fine, but turns out, it needed to be removed:

    public $useTable = 'contacts';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an application, where I do have few different windows implemented, where
We have a few different programs all compiled together in the same suite, recently
I have tried this a few different ways and it always seems to fail.
I have tried a few different fixes using JQuery and CSS Tricks, but I
I have few layouts (different DataTemplates) with video controls. Creation of this video controls
I have a few different types of companies that can access my web application
http://www.raymondselda.com/php-contact-form-with-jquery-validation/ I'm trying a few different contact forms including the one above. I have
In my MVC application I have a few different roles: Admin, General User, etc.,
I have a few different apps which need robust database-backed job/task queues, and so
I have a few different QGlWidget based display widgets which I need to embed

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.