This will not work.
When you refresh the page, the value $attnamewill change. This will happen when you submit the form. Thus, the actual name you are checking will change and will not be the same as the new one $attname.
Put the following after the line echo $attname;:
print_r($_POST);
Also, to work correctly, you need to insert the tag <input>into the tag <form>, for example:
<form method="POST">
<input>...</input>
</form>
source
share