If the sub1 has been submitted to show the submit button of sub2 and show its value, it will give a notice of:
Notice: Undefined index: sub1
though the submit button is already there and it does not give the value of sub1
What is the reason?
<html>
<head>
<title>test</title>
</head>
<form method="post">
<input type='submit' name='sub1' value='sub1'>
<?php
if(array_key_exists('sub1',$_POST))
{
echo"<input type='submit' name='sub2' value='sub2'>";
}
if(array_key_exists('sub2',$_POST))
{
echo $_POST['sub1'];
}
?>
</form>
</html>
As newz leads to, change the field that you are expecting to have the myid value to type ‘hidden’. Then it should pass the value correctly. You will have to add a submit button, and set the name to something else besides ‘myid’.