Tüm alanlar benim MySQL Veritabanı kaydedilir ediliyor

1 Cevap php

Benim form sınıf:

<?php

require_once ('Zend\Form.php');

class Sergio_Form_registrationform extends Zend_Form {
    public function init(){     
        /*********************USERNAME**********************/
        $username = new Zend_Form_Element_Text('username');
        $alnumValidator = new Zend_Validate_Alnum();

        $username   ->setRequired(true)
                    ->setLabel('Username:')
                    ->addFilter('StringToLower')
                    ->addValidator('alnum')
                    ->addValidator('regex', false, array('/^[a-z]+/'))
                    ->addValidator('stringLength',false,array(6,20));
        $this->addElement($username);

        /*********************EMAIL**********************/
        $email = new Zend_Form_Element_Text('email');
        $alnumValidator = new Zend_Validate_Alnum();


        $email      ->setRequired(true)
                    ->setLabel('EMail:')
                    ->addFilter('StringToLower')
                    ->addValidator('alnum')
                    ->addValidator('regex', false, array('/^[a-z]+/'))
                    ->addValidator('stringLength',false,array(6,20));
        $this->addElement($email);

        /*********************PASSWORD**********************/
        $password = new Zend_Form_Element_Password('password');
        $alnumValidator = new Zend_Validate_Alnum();


        $password   ->setRequired(true)
                    ->setLabel('Password:')
                    ->addFilter('StringToLower')
                    ->addValidator('alnum')
                    ->addValidator('regex', false, array('/^[a-z]+/'))
                    ->addValidator('stringLength',false,array(6,20));
        $this->addElement($password);

        /*********************NAME**********************/
        $name = new Zend_Form_Element_Text('name');
        $alnumValidator = new Zend_Validate_Alnum();


        $name       ->setRequired(true)
                    ->setLabel('Name:')
                    ->addFilter('StringToLower')
                    ->addValidator('alnum')
                    ->addValidator('regex', false, array('/^[a-z]+/'))
                    ->addValidator('stringLength',false,array(6,20));
        $this->addElement($name);

        /*********************LASTNAME**********************/
        $lastname = new Zend_Form_Element_Text('lastname');
        $alnumValidator = new Zend_Validate_Alnum();


        $lastname   ->setRequired(true)
                    ->setLabel('Last Name:')
                    ->addFilter('StringToLower')
                    ->addValidator('alnum')
                    ->addValidator('regex', false, array('/^[a-z]+/'))
                    ->addValidator('stringLength',false,array(6,20));
        $this->addElement($lastname);

        /*********************DATEOFBIRTH**********************/
        $dateofbirth = new Zend_Form_Element_Text('dateofbirth');
        $alnumValidator = new Zend_Validate_Alnum();


        $dateofbirth->setRequired(true)
                    ->setLabel('Date of Birth:')
                    ->addFilter('StringToLower')
                    ->addValidator('alnum')
                    ->addValidator('regex', false, array('/^[a-z]+/'))
                    ->addValidator('stringLength',false,array(6,20));
        $this->addElement($dateofbirth);

        /*********************AVATAR**********************/
        $avatar = new Zend_Form_Element_File('avatar');
        $alnumValidator = new Zend_Validate_Alnum();


        $avatar     ->setRequired(true)
                    ->setLabel('Please select a display picture:');
        $this->addElement($avatar);

        /*********************SUBMIT**********************/

        $this->addElement('submit', 'login', array('label' => 'Login'));
    }
}
?>

Ve burada bir şeyler saklıyorum:

<?php

require_once ('Zend\Controller\Action.php');

class RegistrationController extends Zend_Controller_Action {
    //For each of these methods, you MUST have another phtml file in the respective View folder.
    public function indexAction(){
        $form = new Sergio_Form_registrationform();
        $this->view->form = $form;
    }

    public function init(){
        $this->_setParam('db',Zend_Db_Table_Abstract::getDefaultAdapter());
    }

    public function saveforminformationAction(){
        $form = new Sergio_Form_registrationform();
        $request = $this->getRequest();

        //if($request->isPost() && $form->isValid($_POST)){         
            $data = $form->getValues();
            unset($data['login']);
            $db = $this->_getParam('db');

            $db->insert('user',$data);          
        //}     
    }
}

?>

Ve burada işler kaydediliyor nasıl bir ekran görüntüsü:

alt text

Ben yanlış ne yapıyorum? Ben yazmak bile tarihler kaydediliyor değil.

İşte tablo yapısı:

alt text

1 Cevap

Sen Formuna POST'ed ayarı değerleri değildir.

Ile uncomment Ya

$form->isValid($_POST)

veya çağrı

$form->populate($_POST)