$success = $db->update('ad_reference', $data);
    if ($success == 1) {
        $alert_output = $message->success_dialog('Add info saved. ' . $link->paint('grlx_ad_list'));
    }
}
if ($_POST && !$ad_id) {
    $data = array('title' => $title, 'code' => $code, 'date_created' => $db->NOW(), 'source_id' => '3');
    $ad_id = $db->insert('ad_reference', $data);
    if ($ad_id > 0) {
        $alert_output = $message->success_dialog('Add created. ' . $link->paint('grlx_ad_list'));
    }
}
/*****
 * Display logic
 */
$link->preset('adsense_help');
if ($ad_id) {
    $ad_info = get_ad_info($ad_id, $db);
    $instruction_output = 'Edit your AdSense code, ' . $link->paint() . ', below.';
} else {
    $ad_info['title'] = 'New';
    $instruction_output = 'Edit your AdSense code, ' . $link->paint() . ', below.';
}
if ($ad_info) {
    $ad_output = <<<EOL
<label for="title">Title (for your reference)</label>
<input type="text" style="width:10rem" name="title" id="title" value="{$ad_info['title']}"/>

<label for="code">AdSense Code</label>
<textarea name="code" id="code" rows="10">{$ad_info['code']}</textarea>