If I want to check for input of an integer I've got the following (I
get the form input with $input = "$_POST[input]"):
if(!ereg("^[0-9]+$",$_POST[input])) {
echo "Input is incomplete or incorrect.";
}
If, instead of only getting one 'input' I wanted to get n instances of
input, I'd generate input fields for each of n instances I want in a
for loop, then get the input with:
$input[$cnt] = $_POST["input"][$cnt];
Of course, then if I've got the following:
if(!ereg("^[0-9]+$",$_POST["input"][$cnt])) {
echo "Input is incomplete or incorrect.";
}
I'll get the error output if or if not the input was correct or as
intended (in this case integer(s) only). It's clearly an issue with
either the formatting of the ereg condition, or with getting the input
data itself (I'm not certain which). I've had a few ideas and changed
a few things, included a few others, etc.; but I've gotten nowhere
with it on my own yet and instead of wasting others' time with giving
those incorrect examples on here I'd be open to (and grateful for)
insights on what I ought to do in order to get this to work.
Thank you,
- Oeln
get the form input with $input = "$_POST[input]"):
if(!ereg("^[0-9]+$",$_POST[input])) {
echo "Input is incomplete or incorrect.";
}
If, instead of only getting one 'input' I wanted to get n instances of
input, I'd generate input fields for each of n instances I want in a
for loop, then get the input with:
$input[$cnt] = $_POST["input"][$cnt];
Of course, then if I've got the following:
if(!ereg("^[0-9]+$",$_POST["input"][$cnt])) {
echo "Input is incomplete or incorrect.";
}
I'll get the error output if or if not the input was correct or as
intended (in this case integer(s) only). It's clearly an issue with
either the formatting of the ereg condition, or with getting the input
data itself (I'm not certain which). I've had a few ideas and changed
a few things, included a few others, etc.; but I've gotten nowhere
with it on my own yet and instead of wasting others' time with giving
those incorrect examples on here I'd be open to (and grateful for)
insights on what I ought to do in order to get this to work.
Thank you,
- Oeln
Comment