A module that exports user data
I am currently developing a module that exports user data based on profile fields. I have an admin form section for the user that allows them to select the profile fields they want exported from the user data table. I have a php page that exports data from the database into an excel spreadsheet. So I gues I'm looking for the best way to combine them so that the user enters the data in the form and then the form data is processed and an excel spreadsheet is populated with the relevant information that the user selects. They can then save this to their desktop. Is the best way to include a form in the module and then have an action on the form that uses the function in the included code? are there any good examples out there?
thanks
sarah

how can you use the settings from the drupal file to access db?
is there an include line that can be used in the top of the php file? hmm
example code
So in this function I have the form submitting to a php file stored in the same directory of the module I am creating. I want to access other database entries in the php file to print to excel. i thought about using javascript but i would prefer to just submit straight to the form that creates the excel spreadsheet:
<?php
function exportUsersToExcel_admin_settings() {
$output = '';
$profileFieldsTitleArray = array();
$profileFieldsNameArray = array();
$uidArray = array();
$counter = 0;
$count = 0;
$output.='<h2>Please select the user details you want to include in the excel spreadsheet print out for user data</h2>';
/*$form['exportUsersToExcel_details'] = array(
'#type' => 'textfield',
'#title' => t('Zoho API Key.'),
'#description' => t('The Zoho API key.'),
'#default_value' => variable_get('zoho_api_key', FALSE),
);
return system_settings_form($form);*/
$results = db_query("SELECT uid FROM users");
while ($user = db_fetch_object($results)) {
$uidArray[$counter] = $user->uid;
$counter ++;
}
$result = db_query("SELECT title, name FROM profile_fields");
while ($node = db_fetch_object($result)) {
$profileFieldsTitleArray[$count] = $node->title;
$profileFieldsNameArray[$count] = $node->name;
$count ++;
}
$output .= '--------------------------------------------------------------------------------------------------------------------------------------------------------';
/* javascript */
$output .='<SCRIPT LANGUAGE="JavaScript">function printuserdata()
{
alert ("Got to the printuserdata function!")
}
</script>';
/* form */
$output .='<table cellpadding="2" cellspacing="2" border="1" width="600px">';
/*$output .='<form onsubmit="return printuserdata(this);" method="post">';*/
$output .='<form action="modules/ExportUsersToExcel/givemeusers.php" method="post">';
for ($i = 0; $i < count($profileFieldsTitleArray); $i ++)
{
$output .= '<tr><td width="400px"><label>' . $profileFieldsTitleArray[$i] . ': </label></td><td width="50px"><div align="center"><input name="' . $profileFieldsNameArray[$i] . '" type="checkbox" value="' . $profileFieldsNameArray[$i] . '" checked="checked" /></div></td></tr>';
}
$single_value = implode(",", $uidArray);
$output .= '<input type=hidden name="single_value" value="'.htmlspecialchars($single_value).'">';
$output .='</table>';
$output .= '--------------------------------------------------------------------------------------------------------------------------------------------------------';
/*$output .= '<input name="submit" type="submit" value="Export" onclick="printuserdata"/></form>';*/
$output .= '<input name="submit" type="submit" value="Export"/></form>';
drupal_set_message($output);
}
?>