4
Use the class/xoopsform. Look in the xoopsform directory for the available form elements.
Submit form example:
// USER SUBMIT FORM
include XOOPS_ROOT_PATH."/header.php";
include_once XOOPS_ROOT_PATH."/class/xoopsformloader.php";
$formlabel = _MD_ADDNEWLINK;
$formname = "usersubmitform";
$formaction = XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/submit.php';
$formmethod = "post";
$formaddtoken = "false";
$btnlabel = _MD_ADD;
$sform = new XoopsThemeForm($formlabel, $formname, $formaction, $formmethod, $formaddtoken = "false");
$sform->setExtra('enctype="multipart/form-data"');
// Title
$sform->addElement(new XoopsFormText(_MD_TITLE, 'title', 40, 60, $title), true);
// Description
$sform->addElement(new XoopsFormTextArea(_MD_DESCRIPTION, 'description',$description,4,50), true);
// Submit buttons
$button_tray = new XoopsFormElementTray('','');
$submit_btn = new XoopsFormButton('', 'post', $btnlabel, 'submit');
$button_tray->addElement($submit_btn);
$sform->addElement($button_tray);
$sform->display();
The submitted form goes to submit.php
include "header.php";
$myts =& MyTextSanitizer::getInstance();
// TITLE
$title = isset($_POST["title"]) ? $myts->addSlashes(($_POST["title"]);
// DESCRIPTION
$description = $myts->addSlashes($_POST["description"]);
$newid = $xoopsDB->genId($xoopsDB->prefix("modulename_table")."_lid_seq");
$sql = sprintf("INSERT INTO %s (lid, title, description) VALUES (%u, '%s', '%s')", $xoopsDB->prefix("modulename_table"), $newid, $title, $description);
$xoopsDB->query($sql);
I suggest studying Herve's News module for help. Take a look at news/submit.php and his submit form at news/include/storyform.inc.php.