且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Textarea在php中处理?

更新时间:2023-12-04 13:01:58

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
==================