[英]passing textarea data from view to controller codeigniter
I have a form in my home_view.php
that uses textarea that goes like this: 我的home_view.php
中有一个使用textarea的表单,如下所示:
<form action="<?php echo base_url();?>add" method="post">
<textarea name="add-list" id="add-list" rows="10" cols="75"> </textarea>
<input type="submit" id="add-btn" class="btn btn-primary" value="Add" />
</form>
In my controller, I have this: 在我的控制器中,我有这个:
public function add(){
$value = $this->input->post('add-list');
echo "<script type='text/javascript'>alert('$value'); window.location.href='".base_url()."'</script>";
//more code here
}
The problem is the alert only pops up when I have a one-liner input. 问题是仅当我输入单线输入时才会弹出警报。 How can I get all the inputs of the user including new line ('\\n')? 如何获得用户的所有输入,包括换行符('\\ n')?
您可以使用nl2br函数:
$value = nl2br($this->input->post('add-list'));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.