Question

in the yii documentation it says:

foreach($_POST['LoginForm'] as $name=>$value)
{
    if($name is a safe attribute)
        $model->$name=$value;
}

what does the array LoginForm come from? which attribute is it coupled to?

Was it helpful?

Solution

In PHP, $_POST contains the input fields 'posted' from an HTML form.

In an HTML form, items have names

Address: <input type='text' name='LoginForm[addr]'>
City: <input type='text' name='LoginForm[city]'>
ST: <input type='text' name='LoginForm[st]'>

So when PHP provides this input to the script it makes the input into an array by the names, which you can iterator over with the foreach.

OTHER TIPS

The $_POST Array? if so that is a reserved/predefined variable, and it contents is usually that of the result of submitted forms. Is this what you are asking?

http://www.php.net/manual/en/reserved.variables.php

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top