function hotBookmarks_default_page() { // my page's text and crap... now I call a form $content .= drupal_get_form('hotBookmarks_add_bookmark_form'); return $content; } function hotBookmarks_add_bookmark_form() { $form['id'] = array( '#type' => 'textfield', '#size' => 30, '#description' => t('ID of an item. Example: 773204.') ); $form['type'] = array( '#type' => 'select', '#description' => t('Type of an item.'), '#default_value' => 'p', '#options' => array( 'p' => t('player'), 't' => t('team'), 'm' => t('match'), 'l' => t('league') ), ); $form['name'] = array( '#type' => 'textfield', '#size' => 30, '#description' => t('Name. Example: Bob Sunesson.') ); $form['description'] = array( '#type' => 'textfield', '#size' => 30, '#description' => t('Description (optional). Example: That funny guy, a beloved team member.') ); $form['submit'] = array( '#type' => 'submit', '#value' => t('add bookmark'), '#tree' => TRUE ); return $form; } function hotBookmarks_add_bookmark_form_validate($form,$form_values) { if (!is_numeric($form_values['id'])) { form_set_error('', t('ID should be a numeric value (for example 1265399)')); } if (strlen($form_values['name'])<2) { form_set_error('', t('Name is too short')); } } function hotBookmarks_add_bookmark_form_submit($form_id,$form_values) { global $user; $query = 'INSERT INTO hotBookmarks (`id_bookmark`,`uid`,`type`,`name`,`hattrick_id`,`description`) VALUES (\'\',\''.$user->uid.'\',\''.$form_values['type'].'\',\''.mysql_real_escape_string($form_values['name']).'\',\''.$form_values['id'].'\',\''.mysql_real_escape_string($form_values['description']).'\')'; db_query($query); drupal_set_message('Bookmark added. If even little successes make you happy, it\'s a good occassion to throw a party.'); } ?>