I am having difficulty with this piece of code, I have added the code for the url pieces to the
$query_params array, and if there is any empty values in any of the fields, to fill with the string
'Empty', and then to save/append to the file. The problem is if some variables are missing in the form
or there is empty values, it does not add the 'Empty' string to that particular part of the record that is saved to file.
Here is the code:
<?php
include 'curr.php';
$url = curPageURL();
$query_str = parse_url($url, PHP_URL_QUERY);
$query = parse_str($query_str, $query_params);
#authenticate the user name and password
if (in_array("password", $query_params) && in_array("usrer1", $query_params)) {
for( $i=0; $i < 30; $i++ )
if(empty($query_params[i])) {
$query_params[i] = 'Empty';
}
$file = new SplFileObject("file.csv", "a");
$written = $file->fputcsv($query_params);
echo "TRUE";
}
else{
echo "UNAUTHORIZED";
}
?>
Any help would be appreciated.
$query_paramsfrom? It just appears in your code.