function saveforms($option, $apply = 0) { global $mainframe; $database =& JFactory::getDBO(); $row = new forme_forms($database); $_POST['name'] = JRequest::getVar('name', null, 'POST'); $_POST['title'] = JRequest::getVar('title', null, 'POST'); if ($_POST['formstyle'] == '') { $_POST['formstyle'] = _FORME_BACKEND_EDITFORMS_STYLE_DEFAULT; } if ($_POST['fieldstyle'] == '') { $_POST['fieldstyle'] = _FORME_BACKEND_EDITFORMS_FIELDSTYLE_DEFAULT; } // bind it to the table if (!$row->bind($_POST)) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $row->name = preg_replace("/[^a-zA-Z0-9s]/", "", $row->name); $row->formstyle = stripslashes($row->formstyle); $row->fieldstyle = stripslashes($row->fieldstyle); $row->thankyou = stripslashes($row->thankyou); $row->email = stripslashes($row->email); $row->script_process = stripslashes($row->script_process); $row->script_display = stripslashes($row->script_display); if (empty($row->name) || empty($row->title)) { $mainframe->redirect("index2.php?option={$option}&task=forms", _FORME_BACKEND_FORM_NAME_EMPTY . " "); } // store it in the db if (!$row->store()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } else { if (!$row->id) { $row->id = mysql_insert_id(); } } $row->checkin(); if (!$apply) { $mainframe->redirect("index2.php?option={$option}&task=forms", _FORME_BACKEND_FORMS_SAVE . " "); } else { $mainframe->redirect("index2.php?option={$option}&task=editform&cid=" . $row->id, _FORME_BACKEND_FORMS_SAVE . " "); } }