Specifications

The submit button on this form invokes the store-account action. The code for this action is
as follows:
case ‘store-account’ :
{
if (store_account($normal_user, $admin_user, $HTTP_POST_VARS))
$action = ‘’;
if(!check_logged_in())
display_login_form($action);
break;
}
The store_account() function writes the account details to the database. The code for this
function is shown in Listing 28.4.
LISTING 28.3 store_account() Function from mlm_fns.phpThese Functions Check
Whether or Not a User Is Logged In, and at What Level
// add a new subscriber to the database, or let a user modify their data
function store_account($normal_user, $admin_user, $details)
{
if(!filled_out($details))
{
echo “All fields must be filled in. Try again.<br><br>”;
return false;
}
else
{
if(subscriber_exists($details[‘email’]))
{
//check logged in as the user they are trying to change
if(get_email()==$details[‘email’])
{
$query = “update subscribers set realname = ‘$details[realname]’,
mimetype = ‘$details[mimetype]’
where email = ‘“ . $details[email] . “‘“;
if(db_connect() && mysql_query($query))
{
return true;
}
else
{
echo “could not store changes.<br><br><br><br><br><br>”;
return false;
}
}
Building Practical PHP and MySQL Projects
P
ART V
674
34 7842 CH28 3/6/01 3:46 PM Page 674