cake(?) poll user data and submit to form

I’m a complete cakepHp novice but understand some php.

I have a form that I’m using to get members to renew. The only thing they need to specify is if they are changing how long a term they are renewing (1yr, 2…)

The rest of the data should be polled from their account in the phpMyAdmin database, USER table. The fields of interest are: first_name, last_name, address1, address2, city, province, country, postal_code, email. These should be passed to the form invisibly (i.e. user doesn’t see them, but they go in to the invoice and the INVOICE table).

Additionally, there are 2 fields that will be written into the invoice table: notes (which will be ex. “user-renewal”), and is_renewal (which should = “1”).

Thus far I have:

<form action="/member-renewals" id="UserDisplayForm" method="post" accept-charset="utf-8"> <div style="display:none;"><input type="hidden" name="_method" value="POST"/></div> <ul class="formItemList"> <li> <label>User Type</label> <select name="data[User][user_type_id]" id="UserUserTypeId"> <option value=""></option> <option value="3">1-yr-Student ($40.00)</option> <option value="16">2-yr-Student ($72.00)</option> </select> </li>

But I have no clue how to query and set the other varaibles. At this point the user is already logged in, but I tried:

    <first_name="data[User][first_name]" id="UserFirstName">

to no avail…

Any thoughts? Searches are pointing me to ajax which is well beyond me.

Thanks in advance.
Disclosure: posted here (http://stackoverflow.com/posts/28954186/) as well.
--------------------------
Logging in method (from login.ctp):

[php] <?php
$this->set(‘title_for_layout’, ‘User Login’);
$this->viewVars[‘keywords’] = ‘User Login’;
$this->viewVars[‘description’] = $this->Text->truncate(strip_tags(‘This is where users can login’), 150,array(‘ending’=>’…’, ‘html’=>false,‘exact’=>false));
$this->layout = “default_full_no_h1”;
?>

<?php echo $this->requestAction('/liveEditRegions/getRegion/37'); ?>   
<div class="greenForm">
<h2>Users Login</h2>
<?php echo $this->Session->flash(); ?>
    <?php echo $this->Form->create('User', array('url' => '/' . $this->request->url));?>
    <ul class="formItemList" style="width:350px;padding-bottom:40px !important;"> 
    
        <li><?php echo $this->Form->input('email', array('div'=>false, 'label'=>'Your Email Address'));?></li>
        <li class="clear"></li>
        <li><?php echo $this->Form->input('password', array('div'=>false, 'label'=>'Password'));?></li>  
        <li class="clear"></li>        
        <li style="width:125px;"><button type="submit" class="submitBTN" style="float:left;">Login</button></li>          
        <li style="width:150px;text-align:center;margin-right:0px;margin-left:10px;"><?php echo $this->Html->link('Forgot Your Password','/users/forgotPassword',array('style'=>'line-height:60px;'));?>  </li>
        <li class="clear"></li>                
   </ul>         
            <div class='clear'></div>
<?php echo $this->Form->end();?>
</div>[/php]

Controllers (UsersController.php):

[php] function login() {
$this->forceHTTPS();
if ($this->userAuthenticate(false, true)) {
$this->redirect(’/users/index/’);
}
$this->pageTitle = ‘Login’;
if ($this->request->data) {
if ($user_id = $this->User->validateLogin($this->request->data)) {

            $log = $this->addUserLog($user_id, 'Login');

            $params = array(
                'conditions' => array(
                    'User.id' => $user_id
                ),
                'contain' => array(
                    'UserType'
                )
            );

            $this->User->Behaviors->attach('Containable');
            $user = $this->User->find('first', $params);

            $this->Session->write('User', $user['User']);
            $this->Session->write('UserType', $user['UserType']);

            $this->Session->setFlash('Logged in successfully', 'flash_success');
            /*
              if(!$redirect = $this->Session->read('userRedirected')){
              $this->Session->delete('userRedirected');
              $redirect = '/users/index';
              $this->Session->delete('livetoolsRedirected');
              }
             */
            //$this->redirect($redirect); 
            $this->redirect('/users/index/');
        } else {
            $this->Session->setFlash('Unable to authenticate - please contact the CSPT administrator', 'flash_error');
            $this->request->data['User']['password'] = '';
        }
    }
}[/php]

-----------------------------
This was the OLD renewal procedure (userscontroller.php). The new procedure (posted afterward) the users will select the type of renewal:

[php] function cronRenew() {
/*
December - �Dues are due�:
email is sent to all active members, who have not yet paid, indicating dues are due
invoice is automatically generated for the members� dues
*/

    //Initiate the email component
   /* $email = new CakeEmail();

    $params = array(
        //'fields' => array('User.id', 'User.first_name', 'User.last_name', 'User.address1', 'User.created', 'User.city', 'User.province', 'User.country', 'User.postal_code', 'User.email'),
        'conditions' => array(
            'User.status' => 'active',
            'User.enabled' => '1',
        ),
        'order' => array(
            'User.id'
        ),
        'contain' => array(
            'UserType'
        ),
        'recursive' => 1
    );

    $this->User->Behaviors->attach('Containable');
    $users = $this->User->find('all', $params);

    //now that we have all active users, lets generate them invoices for renewal of memberships
    $errorEmailList = array();
    foreach ($users as $user) {

        if (isset($user['UserType']) && $user['UserType']['annual_dues_amount'] > 0 && !$this->User->hasUserPaidForTheComingYear($user['User']['id'])) {

            //Create the Invoice
            $invoice = array(
                'Invoice' => array(
                    'user_id' => $user['User']['id'],
                    'first_name' => $user['User']['first_name'],
                    'last_name' => $user['User']['last_name'],
                    'address1' => $user['User']['address1'],
                    'city' => $user['User']['city'],
                    'province' => $user['User']['province'],
                    'country' => $user['User']['country'],
                    'postal_code' => $user['User']['postal_code'],
                    'email' => $user['User']['email'],
                    'notes' => "User Membership Renewal",
                    'is_renewal' => '1',
                    'InvoiceItem' => array(
                        '0' => array(
                            'name' => 'User Membership Renewal',
                            'description' => 'Renewal for ' . $user['User']['first_name'] . ' ' . $user['User']['last_name'],
                            'price' => $user['UserType']['annual_dues_amount'],
                            'quantity' => '1',
                            //'hst_rate'=>$this->User->taxRate
                            'hst_rate' => 0
                        )
                    )
                )
            );[/php]

New renewal method (usercontroller.php):

[php] # Send email of the Overdue @02/March/2015
function cronInvoiceOverdueNew() {

    //Initiate the email component
    $email = new CakeEmail();

    $month = date('m');
    if($month < 3 && $month > 5){
    	exit;
    }

    $params = array(
        'conditions' => array(
            'User.status' => 'active',
            'User.enabled' => '1',
        ),
        'order' => array(
            'User.id'
        ),
        'contain' => array(
            'UserType'
        ),
        'recursive' => 1
    );

    $this->User->Behaviors->attach('Containable');
    $users = $this->User->find('all', $params);
    
    $errorEmailList = array();
    foreach ($users as $user) {
        $inGoodStanding = $this->User->isUserInGoodStanding($user['User']['id']);
        $userPaidLastYear = $this->User->hasUserPaidForThisYearInTheLastYear($user['User']['id']);
        if ($inGoodStanding == false && !$userPaidLastYear) {
            try {
            	//$month = '5';
                if ($month == '3') {
                    /* $message = "Attention " . $user['User']['first_name'] . " " . $user['User']['last_name'] . "\n\n" . "This is a notification to let you know you have outstanding invoice(s) that must be paid within a month or they will be charged a $10 late fee.\n\n" . 
                      "Thanks\n" .
                      */
                    /*$message = "You have an outstanding membership renewal invoice. Please follow the following link to pay your annual membership dues. A $10.00 late fee will be charged to invoices not paid by the end of February.\n\n" .
                            "Username: " . $user['User']['email'] . "\n" .
                            "Thank you for your continuing support \n" .
                      $message = "Thank you for your patience while undergoing site wide upgrades. Please note there will be no penalty for late renewals thus far. Please login and renew your account by visiting the 'Renewals' link at the bottom of the 'Memberships' dropdown. Please select your correct membership type and submit. An invoice will be created which you can select by clicking 'view' and pay by following through. A late fee of $10 will apply commencing May 2nd, 2015.";       

                    $email->subject('Avoid late fee for annual dues @ ' . Configure::read('Site.name'));
                } elseif ($month == '4') {
                    /* $message =  "Attention " . $user['User']['first_name'] . " " . $user['User']['last_name'] . "\n\n" . 
                      "This is a notification to let you know you have outstanding invoice(s) that if not payed by months end will have a $10 late fee added.\n\n" .
                      "Thanks\n" .
                     */
                    /*$message = "You have an outstanding membership renewal invoice. Please follow the following link to pay your annual membership dues. A $10.00 late fee will be charged to invoices not paid by the end of February.\n\n" .
                            "Username: " . $user['User']['email'] . "\n" .
                            "Thank you for your continuing support \n" .                               
                      $message = "Please log in and renew your account by visiting the \"Renewals\" link at the bottom of the \"Memberships\" dropdown. Please select your correct membership type and submit. An invoice will be created which you can select by clicking 'view' and pay by following through. A late fee of $10 will apply after 30 days, commencing May 2nd, 2015.";      

                    $email->subject('Last reminder for dues renewal @ ' . Configure::read('Site.name'));
                } elseif ($month == '5') {
                    /*$message = "Attention " . $user['User']['first_name'] . " " . $user['User']['last_name'] . "\n\n" . "This is a notification to let you know you have outstanding invoice(s).\n\n" .
                            "Thanks\n" .
                    $message = "Urgent: your account must be renewed by today to avoid late fees. Please log in and renew your account by visiting the \"Renewals\" link at the bottom of the \"Memberships\" dropdown. Please select your correct membership type and submit. An invoice will be created which you can select by clicking 'view' and pay by following through. A late fee of $10 will apply commencing tomorrow, May 2nd, 2015.";        
                    
                    $email->subject('Outstanding Invoices @ ' . Configure::read('Site.name'));
                }


                $message .= "\n\n Renewing your membership allows you to be nominated for the Society awards, stand for election to various committees and, when appropriate, ensures your student's access to presentation and travel awards. The funds collected from membership dues and donations support the educational activities of the Society including the Trainee Travel Bursaries.";
                
                $email->lineLength = 200;
                $email->from(Configure::read('Site.contact.email'));
                $email->sender(Configure::read('Site.contact.noreply'));
                $email->to($user['User']['email']);
                $email->bcc('[email protected]');
                $email->send($message);
                //echo "<br/>".$user['User']['email']."<br/><br/>";
                echo nl2br($message);
                //echo "<hr/><br/><br/>";
            } catch (Exception $e) {
                $errorEmailList[] = $user['User']['first_name'] . ' ' . $user['User']['last_name'] . ' - ' . $user['User']['email'];
            }
            //die();				
        }
    }
    die('Reminder Email Cron Completed');
}[/php]

I feel bad that no one has been able to help you.

I don’t know cakephp, there is a specific stackoverflow tag http://stackoverflow.com/tags/cakephp , and a support freenode http://webchat.freenode.net/?channels=cakephp&uio=MT1mYWxzZSY5PXRydWUmMTE9MjQ2b8

Thank you, I will definitely take a look!

Sponsor our Newsletter | Privacy Policy | Terms of Service