I’ve got a problem with a webform that uses PHP. I’m sure it’s very obvious but can’t find the problem.
What I want to do is basically enter a numerical value into a field on a form, which then sends the value to a mysql database, requesting a record linked to that value,
The problem I am getting is that the value is not being taken properly when I hit the ‘submit’ button, but will take the previous value that was submitted a previous query.
For example, I want to retrieve a record that has an ‘id’ of 1. I enter ‘1’ into the field (the id of the field is ‘identry’), but I get an error. The error basically signifies that I have not entered a value into the ‘id’ field for some reason. Then I access the search field again, enter a value of ‘2’, and hit the ‘submit’. I then get a result that it has just accessed record with ‘id’ of ‘1’ (the previous query!!!!)
Any ideas??
This is my code for the form…..
<form id="form1" name="form1" method="post" >
<table width="400" border="0">
<tr>
<td width = "150" ><div align="right">HPOV reference </div></td>
<td width = "150"><label>
<input name= "identry" type="text" id="identry" />
</label></td>
<td width = "100"><label>
<div align="left">
<input name="Submit" type="submit" onclick="MM_openBrWindow('HPOVwindow.php?id=<?php echo $_POST['identry']; ?>','','toolbar=yes,width=1000,height=1000')" />
</div>
</label></td>
</tr>
</table>
</div>
</form>
I think its how I submit the variables in the first instance but can’t find out how to do this.
You’re posting the previous entry when you submit your form.
PHP can’t handle data on the client side until it’s sent to the server.
This line:
<?php echo $_POST['identry']; ?>is telling PHP to fill the value that was posted to it, which would be the previous entry. What you meant was:document.getElementById("identry").valueEdit: So the line that enters the value would look something like this:
and just try the following: