[eluser]mrwilson1[/eluser]
I have data that is being written from a form and going into a db, but I am trying to make a txt backup of it as well.
All data validates, get written to the db but the data will not write to the file. The post_backups directory is under applications with the controller, models and views.
Code:
// field name, error message, validation rules
$this->form_validation->set_rules('post_title', 'title', 'trim|required|htmlspecialchars');
$this->form_validation->set_rules('post', 'Post', 'trim|required|min_length[5]');
$this->form_validation->set_rules('source', 'source', 'trim');
$this->form_validation->set_rules('owner', 'No owner given', 'trim|required');
$this->form_validation->set_rules('post_cat', 'Category', 'trim|required');
$this->form_validation->set_rules('artist', 'Artist', 'trim|max_length[50]');
$this->form_validation->set_rules('link', 'link', 'trim|max_length[300]');
$this->form_validation->set_rules('new_rel', 'New Release', 'trim|max_length[20]');
$this->form_validation->set_rules('new_artist', 'New artist', 'trim|max_length[20]');
$this->form_validation->set_rules('album', 'Album', 'trim|htmlspecialchars');
$this->form_validation->set_rules('social', 'Social', 'trim|htmlspecialchars|max_length[15]|min_length[6]');
$this->form_validation->set_rules('album', 'Album', 'trim');
$this->form_validation->set_rules('tag', 'Tags', 'trim');
$this->form_validation->set_rules('post_status', 'Status', 'required|trim|callback_draft');
if ($this->form_validation->run() == TRUE){
$this->post_model->add_record($data);
$this->post_model->add_record1($data1);
$this->post_model->add_record2($data2);
// problem starts here
$this->path = "system" . DIRECTORY_SEPARATOR . "application" . DIRECTORY_SEPARATOR . "post_backups" . DIRECTORY_SEPARATOR;
$post_title = $this->input->post('post_title');
$this->file = $this->path . $post_title . 'txt';
$string = $this->input->post('post');
if(write_file($this->file, $string))
{
redirect('post/display_posts');
}else {
echo "File not written";
}
}
This seems awfully simple but Im not seeing where Im going wrong.
Thanks