[eluser]riwakawd[/eluser]
I am trying to write a and ad my post function but not working it is not posting the username
but re posting
$db['default']['username'] = $db['default']['password'] = '';
It should post the username.
On my controller
Code:
public function index() {
if($this->input->server('REQUEST_METHOD') =='POST') {
$this->_setDatabase();
}
$this->load->view('welcome_message');
}
protected function _setDatabase() {
$this->load->helper('file');
$this->lang->load('english', 'english');
$output = '<?php' . " if ( ! defined('BASEPATH')) exit('No direct script access allowed'); \n";
$output .= "\n";
$output .= $this->lang->line('text_database') . "\n";
$output .= "\n";
$output .= '$' . "active_group = 'default'; \n";
$output .= '$' . "active_record = TRUE; \n";
$output .= "\n";
$output .= '$db' . "['default']['hostname'] = 'localhost'; \n";
$output .= '$db' . "['default']['username'] =" . $this->input->post('db_username'); "\n";
$output .= '$db' . "['default']['password'] = ''; \n";
$output .= '$db' . "['default']['database'] = ''; \n";
$output .= '$db' . "['default']['dbdriver'] = 'mysql'; \n";
$output .= '$db' . "['default']['dbprefix'] = ''; \n";
$output .= '$db' . "['default']['pconnect'] = TRUE; \n";
$output .= '$db' . "['default']['db_debug'] = TRUE; \n";
$output .= '$db' . "['default']['cache_on'] = FALSE; \n";
$output .= '$db' . "['default']['cachedir'] = ''; \n";
$output .= '$db' . "['default']['char_set'] = 'utf8'; \n";
$output .= '$db' . "['default']['dbcollat'] = 'utf8_general_ci'; \n";
$output .= '$db' . "['default']['swap_pre'] = ''; \n";
$output .= '$db' . "['default']['autoinit'] = TRUE; \n";
$output .= '$db' . "['default']['stricton'] = FALSE; \n";
write_file(DIR_CMS . 'install/config/database.php', $output, 'r+');
}
View
Code:
<?php echo form_open();?>
<?php
$data = array(
'name' => 'db_username',
'id' => 'db_username',
'value' => ''
);
;?>
<?php echo form_input($data);?>
<?php echo form_submit('mysubmit', 'Submit Username!');?>
<?php echo form_close();?>