如何使用 php 设置文本区域的值? [英] How can i set the value of a text area with php?

查看:33
本文介绍了如何使用 php 设置文本区域的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个问题:-
1.我需要能够设置一个textarea的值
2.然后我需要再次获取文本区域的值以进行更新.我看到文本区域没有值"标签或其他东西..所以我不知道如何通过 PHP 做到这一点.我试过类似

I have two issues:-
1. I need to be able to set the value of a textarea
2. I need to then get the value of the text area again for updating. I see that text area does not have a 'value' tag or something.. so I am not sure how to do this via PHP. I tried something like

print("<textarea cols='15' rows='2' name='textdesc'>$info_desc</textarea>");

设置它.但是没有运气,然后我在检索时会遇到同样的问题.

to set it. But no luck and then i will have the same problem when retrieving.

推荐答案

在 HTML 中设置值...

To set the value in HTML...

<textarea cols="15" rows="2" name="textdesc"><?php echo htmlspecialchars(
    $info_desc, ENT_QUOTES, 'UTF-8') ?></textarea>

要检索它(假设您的表单发出 POST 请求)...

To retrieve it (assuming your form issues a POST request)...

if (isset($_POST['textdesc'])) {
    $textdesc = $_POST['textdesc'];
}

这篇关于如何使用 php 设置文本区域的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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