W np.: php-ie, lista pól z formularza jest traktowana jako tablica ($_POST => method="post"), a tu można pokusić się o użycie np. foreach-a (do iterowania po nazwach i wartościach pól z formularza), co np. sprawdzenie wartości kilkunastu pól (o różnych nazwach), sprowadza do jednego if-a.
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
ob_start();
var_dump($_POST);
$var_dump = ob_get_contents();
ob_end_clean();
$post_variable = '';
foreach($_POST as $variable_name => $variable_value) {
if (empty(trim($variable_value))) $variable_value = 'null';
$post_variable .= $variable_name.' = '.$variable_value.PHP_EOL;
}
} else {
$var_dump = '';
$post_variable = '';
}
?>
<!doctype html>
<html>
<head>
<style>
input {
display: block;
margin: 0.5em;
}
input[type="submit"] {
margin: 1em 0;
}
p {
font-weight: bold;
margin: 0.5em 0;
}
form {
margin-top: 2em;
}
</style>
</head>
<body>
<p>var_dump</p>
<?php echo $var_dump; ?>
<p>foreach</p>
<pre><?php echo $post_variable; ?></pre>
<form method="post">
<label for="input1">Label1</label>
<input type="text" id="input1" name="input1" placeholder="input1">
<label for="input2">Label2</label>
<input type="text" id="input2" name="input2" placeholder="input2">
<label for="input_lorem">Label3</label>
<input type="text" id="input_lorem" name="input_lorem" placeholder="input_lorem">
<label for="input_ipsum">Label4</label>
<input type="text" id="input_ipsum" name="input_ipsum" placeholder="input_ipsum">
<label for="input3">Label5</label>
<input type="text" id="input3" name="input3" placeholder="input3">
<input type="submit" value="submit">
</form>
</body>
</html>
[ edit ]
Z treści post-a nie wynikało wprost, że tu chodzi o python-a, ale z komentarzy już tak ...
więc może te linki okażą się przydatne:
How to Run Python on XAMPP web server
Processing HTML form data with Python
Retrieving HTML From data using Flask