1

I have a PHP page with a list of items pulled from a database. Each item has an input form next to it, and right at the bottom, a submit button.

How can i do a POST check to find out which inputs have had data added? I can get the data, but how do I know the names of the particular inputs that have been filled?

2
  • 2
    Show a snippet of your HTML and your current PHP code Commented Feb 28, 2012 at 1:18
  • " Each item has an input form next to it" Is it input form or input box ? Commented Feb 28, 2012 at 1:36

2 Answers 2

2

Iterate over $_POST and list the keys which have nonempty values.

foreach ($_POST as $key => $value) {
  if (!empty($value)) {
    echo $key . " was filled in.";
  }
}
Sign up to request clarification or add additional context in comments.

Comments

0

Take a look at the isset() function of PHP - http://php.net/manual/en/function.isset.php.

For Example,

<?php
if(isset($_POST['somevar'])) {
    // if the value has been set, this code is executed
} else {
 //value not set, so execute this code.

}
?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.