I have a php file, in it the code is bellow:
<?php
if (isset($_GET['action']) && $_GET['action'] == 'view') {
echo "get";
print_r($_GET);
} else {
}
?>
<html>
<form method="get" action="<?php echo ($_SERVER['PHP_SELF'] . '?action=view&id=4') ; ?>">
<input type="text" />
<input type="submit" />
</form>
</html>
If I click the submit, why the echo "post"; and print_r($_POST); do not output to the screen?
EDIT01
I changed my code to bellow:
<?php
if (isset($_GET['action']) && $_GET['action'] == 'view') {
echo "if ";
var_dump($_GET);
} else {
echo "else ";
var_dump($_GET) ;
}
?>
<html>
<form method="get" action="?action=view&id=4">
<input type="text" name="username" />
<input type="submit" />
</form>
</html>
however, it do not go through the if, it go else.
the screen output is like this:
