You forgot to name your submit button, that's why $_GET['submit']
is never set:
<input type="submit" value="submit" name="submit" />
Remove these closing </input>
- they are all incorrect.
Frage
All I need is: 1. After pressing 'submit' button to get vars to function and use return value. 2. To understand why I can not echo functions return value;
PHP FUNCTION:
function check_if_numbers($x, $y)
{
$permission =0;
if((gettype($x)==gettype($y))&&(gettype($x)=="integer")) {return 1;}
else {return 0;}
}
PHP CODE
<?php
if( isset($_GET['submit']) )
{
$x = htmlentities($_GET['x']);
$y = htmlentities($_GET['y']);
$permission_token=check_if_numbers($x, $y);
echo $permission_token;
}
?>
HTML
<form action="" method="get">
Determine X = <input name='x' id='x' type="text" size="1"></br>
Determine Y = <input name='y' id='y' type="text" size="1"></br>
<font size=2 >Input only integers</font>
<input type="submit" value="submit">
Lösung
You forgot to name your submit button, that's why $_GET['submit']
is never set:
<input type="submit" value="submit" name="submit" />
Remove these closing </input>
- they are all incorrect.
Andere Tipps
A c
is missing when you call chek_if_numbers
and not check_if_numbers
.
2 To understand why I can not echo functions return value;
For old versions of PHP (before 4.3 I think), PHP will echo zero (ie echo(0);
) as boolean false and not 0, and as such it will not display anything on the screen.