CodeIgniter Forums
HELP! disable html in textarea - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: HELP! disable html in textarea (/showthread.php?tid=30613)



HELP! disable html in textarea - El Forum - 05-20-2010

[eluser]codedoode[/eluser]
The title pretty much tells it all. I'm trying to disable the use of html in a textarea. Can anyone shed some light on this subject? Thanks in advance.

this is my controller
Code:
function create()
    {
        $data = array(
            'content' => $this->input->post('content')
        );

        $stripped = strip_tags($data);
        $this->site_model->add_record($data);
        $this->index();
    }

this is my model
Code:
function add_record($data)
    {
        $this->db->insert('data', $data);
    }

what am I doing wrong?


HELP! disable html in textarea - El Forum - 05-20-2010

[eluser]danmontgomery[/eluser]
strip_tags()?


HELP! disable html in textarea - El Forum - 05-23-2010

[eluser]codedoode[/eluser]
bump still need help!


HELP! disable html in textarea - El Forum - 05-23-2010

[eluser]WanWizard[/eluser]
With what exactly?

It seems to me that noctrum already answered your question? Or is there more to this?


HELP! disable html in textarea - El Forum - 05-23-2010

[eluser]codedoode[/eluser]
We'll I'm trying to implement what noctrum said, and I just can't seem to get it to work correctly. Please review the code I posted above, and let me know what I'm doing wrong.


HELP! disable html in textarea - El Forum - 05-23-2010

[eluser]WanWizard[/eluser]
$this->db->insert requires an array as $data.
So it should be something like
Code:
$this->site_model->add_record( array('contents' => $data) );
assuming that the field in your database table is called 'contents'...


HELP! disable html in textarea - El Forum - 05-23-2010

[eluser]codedoode[/eluser]
That didn't work I got a bunch of errors.


HELP! disable html in textarea - El Forum - 05-23-2010

[eluser]WanWizard[/eluser]
Missed that your data is already in an array, but the way you coded the stripped tags made me miss the error.

Code:
function create()
    {
        $data = array(
            'content' => strip_tags( $this->input->post('content') )
        );
        $this->site_model->add_record($data);
        $this->index();
    }



HELP! disable html in textarea - El Forum - 05-23-2010

[eluser]codedoode[/eluser]
Thank you so much for your help. I knew earlier I was on the right track, I originally had:

Code:
strip_tags( 'content' => $this->input('content') )

Thanks again for the help!