user2072618
user2072618

Reputation:

check whether a $_POST exists and value

I am trying to check if $_POST exists and check only for a specific value. In my code I am trying to check for data header=h1. The code works, it checks for data header but I do not know how to specify for value of header i.e check for header=h1

if ($_POST['data']['header']){
    $myBuildPath = Config::$buildPath.Users::$userid.'/'.$item[$this->mainModel->primaryKey].'/';
    foreach (Config::$repository['headersCustomDest'] as $file => $fileDestPath){
    $dest_file = $myBuildPath.$fileDestPath;

    if(file_exists($file)) full_copy($file,$dest_file);
    else echo $file.' does not exist.';
}

Upvotes: 1

Views: 2057

Answers (3)

BenM
BenM

Reputation: 53198

if(isset($_POST['data']['header']) && $_POST['data']['header'] == 'h1')
{
    // blah
}

Should do the trick.

Upvotes: 3

Muthu Kumaran
Muthu Kumaran

Reputation: 17910

Change your condition and check with == with value

if (isset($_POST['data']['header']) && $_POST['data']['header'] == 'h1'){

Upvotes: 0

GarethL
GarethL

Reputation: 1493

Is this what you mean?

if(isset($_POST['data']['header']) && $_POST['data']['header'] == 'h1') {

Upvotes: 1

Related Questions