php - scope of $_POST[] , trying to access $_POST[] variable, getting the undefined index error -
i have these 2 forms submits different blocks of same script. unable access variable of 1 block in other, though both variables in same script.
html form :(1.php)
<html> <form method="post" action="2.php" enctype="multipart/form-data"> </br> choose user name:</font> <input type="text" name="username"> <input type="submit" name="submit" value="save , proceed"> </form> </html> 2.php:
<?php $name=$_post['username']; if ((isset($_post['username'])) && ($_post['submit'] == 'save , proceed')) { $name=$_post['username']; echo $name; if($name=='azra') { ?> <html> <form method="post" action="2.php" enctype="multipart/form-data"></br> enter age:</font> <input type="text" name="age"> <input type="submit" name="submit" value="done"> </form> </html> <?php } } if((isset($_post['age'])) && ($_post['submit'] == 'done')) { $age=$_post['age']; echo $age; if($age==25) { echo "hi" .$name; echo "your age ". $age; echo"you eligible"; } } ?> how access $_post['username'] in code following html form in same script? thank in advance.
if understand want pass username twice. can use hidden input, not visible (only transports data):
<input type="hidden" name="username" value="<?php echo $_post['username']; ?>" />
Comments
Post a Comment