bob jomes bob jomes - 1 year ago 85
HTML Question

dont add rule for certain input field

So I have input fields and when they are submitted, I check to see if their inputted text appears in an array:

<form method="post">
<input type="text" name="1">
<input type="text" name="2">
<input type="text" name="3">
<input type="submit" name="submit">


if(isset($_POST['submit'] {

$array = array('432423', '434', '3', '2', '213');

$success = true;

foreach ($_POST as $key=>$value) {
if (!empty($value) && $key != "submit") {
if (!in_array($value, $array)) {
$success = false;

// TRUE if all contains, FLASE if any one doesn't contain



But if I wanted a certain input field not to have to be checked against the array, how would I do this

Answer Source

Then you probably want to check for another $key != something?


if (!empty($value) && $key != "submit" && $key != "2") {

This would exclude the second input...

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download