I am submitting a form using an href link via POST method. When I submit the form I am not able to get the value of the PHP variable.
Here is my code
if(($_POST)) {
$users1 = $_POST['cityname'];
echo $users1;
echo "shakti";
}
<td align="center">
<form action="searchresult.php" method="POST">
<a href="#" style="text-decoration:none;" onclick="parentNode.submit();" name="an">
</form>
<?php echo $row['city']; ?>
<input type="text" value="<?php echo $row['city'];?>" name="cityname">
</a>
</td>
How can I achieve my desired output?
Thanks!
A Form element inside an anchor tag is invalid HTML .
if(($_POST)) {
$users1 = $_POST['cityname'];
echo $users1;
echo "shakti";
}
<td align="center">
<form action="searchresult.php" name="form1" method="POST">
<?php echo $row['city']; ?>
<input type="text" value="<?php echo $row['city'];?>" name="cityname">
<a href="#" style="text-decoration:none;" onclick="javascript:document.form1.submit();" name="an">SUBMIT</a>
</form>
</td>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.