mercredi 2 septembre 2015

Need help writing variables to a file if they match criteria

I have the following code, want I want to do is write these two variables autoenable and devicetype only if they match from the form submission, otherwise, do not write it to the file. I am not sure how to nest the if statments correctly in the syntax:

   if (fwrite($handle,{"
# $hostname.$domainname
add user $hostname.$domainname {{$username}}
add password $hostname.$domainname {{$password}} {{$enablepw}}
add method $hostname.$domainname {{$method}}
add encryption $hostname.$domainname {{$encrypt}}"
} elseif ($autoenable = "1"){
"add autoenable $hostname.$domainname {{$autoenable}}"
} elseif ($devicetype = "cisco-sb"){
"add userprompt $hostname.$domainname {\"User Name:\"}"
}
}
     ) === FALSE) {
    echo "Cannot write to file ($loginfile)";
 }
 echo "<br>";
 echo "Success, $companyname device $devicename added to file $loginfile";

 fclose($handle);

Any help would be awesome.

Aucun commentaire:

Enregistrer un commentaire