HOW TO TAKE INPUT IN PHP:
Its a very difficult task to take input in PHP, so I have developed a function get_input($num_of_inputs) which takes num of input variable and returns those inputs in an array.
For Example: if i wanted to take 3 inputs
<?php
//DO NOT MODIFY THE CODE
// processing started
function get_input($num_of_inputs){
global $_NUM_OF_INPUTS;
$_NUM_OF_INPUTS = $num_of_inputs;
$inputs = array();
if (isset($_POST['submit'])) {
$value = isset($_POST['input0'])? $_POST['input0'] : null;
for($count = 1; $value != null; $count++){
array_push($inputs, $value);
$value = isset($_POST['input'.$count])? $_POST['input'.$count] : null;
}
}
return $inputs;
}
// processing ends
//change code below
$inputs = get_input(3);
//var dump is used to check the inputs
var_dump($inputs);
// to access specific index use echo $inputs[0];
/*
*
*
*code here
*
*
*
*/
?>
<!-- copy this form and paste it where you wanted that your text boxes will appear -->
<!-- DO NOT MODIFY THE CODE -->
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<?php
for($count = 0; $count < $_NUM_OF_INPUTS; $count++){
printf("Enter input %'02d:", $count+1);
echo ' <input type="text" name="input' . $count .'" value="" /><br />';
}
echo '<input type="submit" name="submit" value="Submit" />';
?>
</form>
Preview LOOKED LIKE BELOW:
