prestashop_newuser Posted February 4, 2014 Share Posted February 4, 2014 Hi, I am doing a small module. In that module I have a form with label your name.So my module code looks like this private function _displayForm() { $this->_html .= ' <form id="myform" method="post" action="'.$_SERVER['REQUEST_URI'].'" enctype="multipart/form-data"> <label for="your-name">'.$this->l('Your Name:').'</label> <input type="text" name="your-name"/> <input type="submit" name="submit_settings" value="'.$this->l('Save Settings').'" class="button" /> </form> '; } public function getContent() { $your_name = Tools::getValue('your-name'); if(Tools::isSubmit('submit_settings')) { if(Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'mytable` (`id`,`your_name`) VALUES ("","'.$your_name.'")' )) { $this->_html .=$this->displayConfirmation($this->l('Settings updated successfully')); } else { $this->_html .= $this->displayError($this->l('You Have Some Errors')); } } $this->_displayForm(); return $this->_html; } When I am submitting the button after entering values for name it is doing save in the database. But there is something different I want. I want that when someone enters the value for your name and click on submit the value will be saved to the database but after submit the form the entered value should show in the form input. So I clearly want that I will not clear the entered values even after the button submit. So can some one tell me how to do this? Any help and suggestions will be really appreciable. Thanks Link to comment Share on other sites More sharing options...
vekia Posted February 4, 2014 Share Posted February 4, 2014 you can save these values to cookie $_COOKIE or use $_POST variable. for example <input type="text" name="your-name" value="'.Tools::getValue('your-name').'"/> Link to comment Share on other sites More sharing options...
Recommended Posts