你能用PHP设置一个表单字段值吗?

编程入门 行业动态 更新时间:2024-10-21 07:39:31
本文介绍了你能用PHP设置一个表单字段值吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用$ _GET函数从url(http:.... / index.html?variable = value)中抽取一个值,这是基本的东西。但是,我需要在表单中使用该值。

通常,我会设置

<?php echo'value ='。$ variable。''; ?>

或类似的东西。但是,我不能在我的表单中使用我正在使用的编辑器中的PHP。

我可以在表单中设置一个值而不使用我的表单中的PHP吗?如果是这样,怎么做?

编辑:使用CMS编辑器我使用的是不能将php代码存储到服务器。 (我正在使用FCKeditor,和Dubral一样)。这是所有CMS使用Wordpress的安全措施。基本上我想发送/设置值的形式与PHP。与javascript相似:document.form.field.value

解决方案

设置默认值的最佳方法现有值)在你的问题中提到 value ='。$ variable。''。

如果您不能使用这种标记,那么您可以使用javascript(无论是使用AJAX引用辅助文件/提要,还是使用相同的变量回显技术),以便在特定字段中替换后的值 $ p $ < script type = 文本/ JavaScript的 > document.form [0] .name.value =<?php echo $ name;?>; < / script>

I use the $_GET function to pull a value with php from the url (http:..../index.html?variable=value), basic stuff. However, I need to use that value in my form.

Typically, I would set

<?php echo 'value="'.$variable.'"' ; ?>

or something to that effect. However, I can't use php inside my form using the editor I'm working with.

Can I set a value in the form without using PHP in my form? If so, how?

Edit: with the CMS editor I'm using you can't store php code to the server. (I'm using FCKeditor. The same used by Dubral). This is a security measure all CMS's use even Wordpress. Basically I want to send/set the value in the form with php. Similar to how javascript does it: document.form.field.value

解决方案

The best way to set default values (ie pre-existing values) within an HTML form is as you mentioned in your question value="'.$variable.'"'.

If you are unable to use markup like that, then you may be able to use javascript (whether referencing a secondary file/feed using AJAX, or using the same variable echoing technique) to replace the values in the specific fields after the page has loaded.

ie

<script type="text/javascript"> document.form[0].name.value = "<?php echo $name; ?>"; </script>

更多推荐

你能用PHP设置一个表单字段值吗?

本文发布于:2023-11-24 22:39:19,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:能用   字段   表单   PHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!