Search code examples
phpcodeignitercodeigniter-2

Posting HTML through $_POST in Codeigniter


This is my form.

<?php echo form_open('welcome/post_large'); ?>

<textarea name="large"></textarea>

<input type="submit" name="mysubmit" value="Submit Post!" />

<?php echo form_close(); ?>

And this is my controller/Method

public function post_large()
{
    echo $this->input->post('large');
}

When i post plain text.It works fine. but when i post html data like <a href="#">link</a>.It post only <.How do i post html through my form.


Solution

  • Try this...

    public function post_large()
    {
        echo htmlspecialchars($this->input->post('large'));
    }