Data that was sent using the POST method is not passed to the script. Through the GET method everything works. Sample code.
<!DOCTYPE html> <html> <head> <title>Title</title> </head> <body> <form method="POST"> <input type="text" name="value"> <input type="submit" name="submit" value="Submit"> </form> </body> </html> <?php ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); if (isset ($_POST['submit'])) { if (isset ($_POST['value'])) { $n = $_POST['value']; function factorial($n) { if ($n <= 1 || $n == 1) { return 1; } else { return $n * factorial($n - 1); } } echo factorial($n) . "<br>"; function factLoop($n) { $result = 1; for ($i = 2; $i <= $n; $i++) { $result = $result * $i; } return $result; } echo factLoop($n); } else { echo "Введіть число"; } } print_r($_POST) ;
Networksay in developer tools? ... By the way, so that the inscription is displayed, enter the number you need to check the value for emptinessif (isset ($_POST['value']) && !empty($_POST['value'])).... because if the post went, then value exists (unless of course there was a field with the same name on the form) - Alexey Shimanskyvalue:10 submit:Submit.. data is transferred .... - Alexey Shimansky