array( 'id' => 'befriend', 'name' => 'befriend', 'action' => BX_DOL_URL_ROOT . 'befriend.php', 'method' => 'post', 'onsubmit' => "return bx_ajax_form_check(this)", ), 'params' => array ( 'db' => array( 'submit_name' => 'do_submit', // we need alternative hidden field name here, instead of submit, becuase AJAX submit doesn't pass submit button value ), ), 'inputs' => array ( 'header1' => array( 'type' => 'block_header', 'caption' => $sCaption, ), 'do_submit' => array( 'type' => 'hidden', 'name' => 'do_submit', // hidden submit field for AJAX submit 'value' => 1, ), 'id' => array( 'type' => 'hidden', 'name' => 'ID', 'value' => $profileID, ), 'Profile' => array( 'type' => 'text', 'name' => 'Profile', 'value' => $member, ), 'message' => array( 'type' => 'textarea', 'name' => 'message', 'colspan' => '2', 'caption' => 'Please enter reason for Friend Request', ), 'submit_send' => array( 'type' => 'submit', 'name' => 'submit_send', 'value' => _t("Send Friend Request"), ), ) ); // generate form or form result content $oForm = new BxTemplFormView($aForm); $oForm->initChecker(); if ($oForm->isSubmittedAndValid()) { $s = BefriendMember($iSenderID) ? "Friend Request Sent" : "Friend Request Sent"; $sPageCode = MsgBox(_t($s)); } else { $sPageCode = $oForm->getCode(); } // output AJAX form submission result if (bx_get('BxAjaxSubmit')) { header('Content-type:text/html;charset=utf-8'); echo $sPageCode; exit; } $sPageCode = $GLOBALS['oSysTemplate']->parseHtmlByName('default_margin.html', array('content' => $sPageCode)); // output ajax popup if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') { $aVarsPopup = array ( 'title' => $_page['header'], 'content' => $sPageCode, ); header('Content-type:text/html;charset=utf-8'); echo $GLOBALS['oFunctions']->transBox($GLOBALS['oSysTemplate']->parseHtmlByName('popup.html', $aVarsPopup), true); exit; } // output regular page $_ni = $_page['name_index']; $_page_cont[$_ni]['page_code'] = $sPageCode; PageCode(); function BefriendMember($iSenderID = 0) { global $profileID; $sMember = clear_xss($_POST['Profile']); $sMessage = clear_xss($_POST['message']); if ( $profileID = 1 ) { $rBefriend = mysql_query("INSERT INTO `sys_friend_list` (`ID`, `Profile`, `Check`, `When`, `message`) VALUES ('$iSenderID', '$sMember', '0', CURRENT_TIMESTAMP, '$sMessage')"); } }