开发者

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 f开发者_如何转开发orm area.

But it is only using value of value attribute() to store in 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.

I am passing values to a html form, from a previous PHP page like this..

<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. In html you use GEt but in php POST. If you don't know about GET or POST try to use $_REQUEST.


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

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

and show your mysql error.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜