PHP如何传递文本框的值到数据库操作

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP如何传递文本框的值到数据库操作相关的知识,希望对你有一定的参考价值。

参考技术A 使用表单不需要在网址中传值
<form
action="update.php"
method="post"
name="form1"
>
<textarea
name="end_check_content8"
wrap="physical"></textarea>
<input
type="hidden"
name="dia_id"
value="<?=$dia_id1?>">
<input
type="hidden"
name="cur_page"
value="<?=$cur_page?>">
<input
type="submit"
name="ok"
value="合格">
<input
type="submit"
name="no"
value="不合格">
</form>
update.php
<?php
echo
'textarea的值为'.$_post['end_check_content8'].'
';
echo
'dia_id的值为'.$_post['dia_id1'].'
';
echo
'cur_page的值为'.$_post['cur_page'].'
';
if($_post['ok'])
echo
'合格'.'
';
else
echo
'不合格'.'
';
?>
参考技术B 使用表单不需要在网址中传值
<form
action="update.php"
method="post"
name="form1"
>
<textarea
NAME="END_CHECK_CONTENT8"
WRAP="PHYSICAL"></textarea>
<input
type="hidden"
name="DIA_ID"
value="<?=$DIA_ID1?>">
<input
type="hidden"
name="CUR_PAGE"
value="<?=$CUR_PAGE?>">
<input
type="submit"
name="ok"
value="合格">
<input
type="submit"
name="no"
value="不合格">
</form>
update.php
<?php
echo
'textarea的值为'.$_POST['END_CHECK_CONTENT8'].'<br>';
echo
'DIA_ID的值为'.$_POST['DIA_ID1'].'<br>';
echo
'CUR_PAGE的值为'.$_POST['CUR_PAGE'].'<br>';
if($_POST['ok'])
echo
'合格'.'<br>';
else
echo
'不合格'.'<br>';
?>
参考技术C <?php
$content=$_POST[END_CHECK_CONTENT8];//取TEXTAREA的值
$link=mysql_connect('localhost','root','');//连接数据库
mysql_select_db('库名');
......
进行你要的操作
.....

如何获取文本框的值 - LibreOffice Base

【中文标题】如何获取文本框的值 - LibreOffice Base【英文标题】:How to get the value of a Text box - LibreOffice Base 【发布时间】:2018-03-20 14:55:13 【问题描述】:

我想做的很简单。

我在 LibreOffice Base 中有一个表单,其中包含一个用于输入一些数据的文本框和一个用于执行宏的按钮。 现在我想通过单击按钮上的宏获取文本框的输入值并使用 Print("...") 函数进行打印。

这是我到目前为止所得到的。不多,但也许是一个开始:

Sub TestMacro
   dim oForm as object
   dim oTextbox as object
   dim content as object

   oForm = thisComponent.drawpage.forms.getByName("form_a")
   oTextbox = oForm.getByName("testbox")
   content = oTextbox.getText()

   Print(content)
End Sub

感谢任何形式的帮助!

【问题讨论】:

【参考方案1】:

我自己找到了答案。关键是让子程序有一个参数,因为宏用于按钮上的执行。在事件中,您可以获得作为表单的 Parent,从那里您可以获得文本框及其当前值。对我来说效果很好。

这里是代码

Sub TestMacro(oEvent as object)

   DIM oForm AS OBJECT
   DIM oField as object
   DIM oTField as object

   'gets the button
   oTField = oEvent.Source.Model
   'gets the parent of the button which is the form
   oForm = oTField.Parent
   'gets the text field based on its name
   oField = oForm.getByName("testbox")
   'prints the value of the textfield
   Print(oField.getCurrentValue)

End Sub

【讨论】:

【参考方案2】:

使用 Access2Base API 会很容易。

【讨论】:

正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center。

以上是关于PHP如何传递文本框的值到数据库操作的主要内容,如果未能解决你的问题,请参考以下文章

jsp中form怎么传递文本框的值和密码框的值到下一页面

jquery:怎么从一文本框获取值到另一文本框?如下图,下文本框输入值,点提交,则值提交到上文本框。

SQL2000数据库中合并两行相同条件的值到列中怎么操作?

c++获取文本框的值

js,php问题。怎么在文本框输入数据后判断是不是超出库存?

jsp button提交一个值到servlet