Textarea在php中处理? [英] Textarea handling in php ?

查看:56
本文介绍了Textarea在php中处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习一些关于在php中使用表单来输入数据的方法,并且有一些问题需要回复。

目前我只是使用addslashes()来处理textarea中的值所以

标点符号被转义,并将其写入表格。

当文本包装在文本框中时,我得到返回值中的新行,

以及我手动输入的新行。

是否可以删除换行换行但是保持用户输入新行

行?

解决方案

Tony B写道:


我正在学习一些关于在PHP中使用表格来输入数据的方法,并且有一些问题可以解决问题。

目前我只是使用addslashes()来处理textarea中的值所以

标点符号被转义,并将其写入表格。

当文本包装在文本框中时我得到一个新的返回值中的行,

以及我手动输入的新行。

是否可以删除换行换行但是保持用户输入新行
line?



首先,你不应该使用addslashes()。如果您正在写入

a MySQL数据库,那么您应该使用mysql_real_escape_string()。


至于新行 - 您的代码如何知道哪些是由

插入的textarea以及哪些是由用户插入的?最好使用首先正确发送

数据。查看textarea的WRAP属性。


-

==================

删除x来自我的电子邮件地址

Jerry Stuckle

JDS计算机培训公司
js ******* @ attglobal.net

==================


3月18日12:18,Jerry Stuckle< jstuck ... @ attglobal.netwrote:


Tony B写道:


我正在学习一些关于在php中使用表单来输入数据,并且有一个



至于新行 - 你的代码如何知道哪些是由

插入的textarea以及哪些是由用户插入的?最好使用首先正确发送

数据。查看textarea的WRAP属性。


-

==================

删除x来自我的电子邮件地址

Jerry Stuckle

JDS计算机培训公司

jstuck ... @ attglobal.net

==================



当然应该是:更好地使用正确发送数据

首先。请参阅textarea的WRAP属性。但这个

与php无关。


;-)


Captain Paralytic写道:


3月18日12:18,Jerry Stuckle< jstuck ... @ attglobal.netwrote:


> Tony B写道:


>>我正在学习一些关于在php中使用表单来输入数据,并且有一个


至于新行 - 您的代码如何知道哪些是由textarea插入的以及哪些是由用户插入的?最好使用首先正确发送
数据。请参阅textarea的WRAP属性。

==================
删除x。来自我的电子邮件地址
Jerry Stuckle
JDS计算机培训公司
jstuck ... @ attglobal.net
=============== ===



当然应该是:最好使用正确的发送数据

。请参阅textarea的WRAP属性。但这个

与php无关。


;-)



True。 :-)


-

==================

删除x来自我的电子邮件地址

Jerry Stuckle

JDS计算机培训公司
js ******* @ attglobal.net

==================


I''m learning a little about using forms in php to enter data, and have a
couple of questions re textarea.
At the moment I just use "addslashes() to process the value from textarea so
that punctuation is escaped, and write this into a table.
When the text wraps in the text box I get a new line in the value returned,
as well as new lines that I enter manually.
Is it possible to remove the wrap new line but keep the user entered new
line ?

解决方案

Tony B wrote:

I''m learning a little about using forms in php to enter data, and have a
couple of questions re textarea.
At the moment I just use "addslashes() to process the value from textarea so
that punctuation is escaped, and write this into a table.
When the text wraps in the text box I get a new line in the value returned,
as well as new lines that I enter manually.
Is it possible to remove the wrap new line but keep the user entered new
line ?

First of all, you shouldn''t be using addslashes(). If you''re writing to
a MySQL database, you should be using mysql_real_escape_string() instead.

As for the new lines - how is your code to know which are inserted by
the textarea and which are inserted by the user? Better to use send the
data correctly in the first place. See the WRAP attribute of a textarea .

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================


On 18 Mar, 12:18, Jerry Stuckle <jstuck...@attglobal.netwrote:

Tony B wrote:

I''m learning a little about using forms in php to enter data, and have a

As for the new lines - how is your code to know which are inserted by
the textarea and which are inserted by the user? Better to use send the
data correctly in the first place. See the WRAP attribute of a textarea .

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================

Surely that should have been: "Better to use send the data correctly
in the first place. See the WRAP attribute of a textarea. But this
has nothing to do with php.

;-)


Captain Paralytic wrote:

On 18 Mar, 12:18, Jerry Stuckle <jstuck...@attglobal.netwrote:

>Tony B wrote:

>>I''m learning a little about using forms in php to enter data, and have a

As for the new lines - how is your code to know which are inserted by
the textarea and which are inserted by the user? Better to use send the
data correctly in the first place. See the WRAP attribute of a textarea .

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================


Surely that should have been: "Better to use send the data correctly
in the first place. See the WRAP attribute of a textarea. But this
has nothing to do with php.

;-)

True. :-)

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================


这篇关于Textarea在php中处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆