简体   繁体   English

HTML值属性表格

[英]HTML value attribute form

Well i heard that Value attribute is just a default attribute, so i used the value attribute to fetch the data from a previous file and fill form area. 好吧,我听说Value属性只是一个默认属性,因此我使用了value属性从先前的文件中获取数据并填写表单区域。

But it is only using value of value attribute() to store in DB. 但是它仅使用value attribute()的值存储在DB中。 For Example if the customer changes value passed in the text box(passed by value attribute) and submit the information the changed value is not being stored in DB rather value stored in value attribute is getting saved. 例如,如果客户更改了在文本框中传递的值(由value属性传递)并提交了信息,则更改后的值未存储在DB中,而是保存了存储在value属性中的值。

I am passing values to a html form, from a previous PHP page like this.. 我正在将值从类似这样的以前的PHP页面传递到html表单。

<form action="parentid1.php" method="post"> 
<label>id:</label> 
<input type="text" name="id" value="<?php echo htmlspecialchars($_GET['id']) ?>" size="50"/> <br/>
 <label>Name:</label>
 <input type="text" name="name" value="<?php echo htmlspecialchars($_GET['name']) ?>" size="50"/><br/> 
<input type="submit" value="submit" /><br/>
</form>

In my next file i am trying yo update the values declared like this: 在我的下一个文件中,我正在尝试更新这样声明的值:

$value = mysql_real_escape_string($_POST['id']);
$value1 = mysql_real_escape_string($_POST['name']);  
$sql = "UPDATE table SET name='$value1'WHERE doi ='$value'";

Here is the case: A form structure of text type will be formed with some value already in it. 在这种情况下:将形成文本类型的表单结构,并且其中已经包含一些值。 Now customer wants to change the data in form box changes it and submits it but the changed is not being saved in the DB rather the previous value is only saved. 现在,客户希望在表单框中更改数据并进行更改,然后提交它,但更改后的数据不会保存在数据库中,而是仅保存以前的值。

What am i doing wrong? 我究竟做错了什么?

It seems that you mix GET and POST data. 似乎您混合了GET和POST数据。 In html you use GEt but in php POST. 在html中使用GEt,但在php POST中使用。 If you don't know about GET or POST try to use $_REQUEST. 如果您不了解GET或POST,请尝试使用$ _REQUEST。

$sql = "UPDATE `table` SET `name`='".$value1."' WHERE `doi`='".$value."'";

$result = mysql_query($sql) or die(mysql_error());

and show your mysql error. 并显示您的mysql错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM