Once the data in the form has been filled out and the admin clicks the Save button, we need to save the information into the database. To start, create a new function of saveSingle()
in restaurants.php:
function saveSingle() { JRequest::checkToken() or jexit( 'Invalid Token' ); global $mainframe, $option; $row =& JTable::getInstance('review', 'Table'); if (!$row->bind(JRequest::get('post'))) { JError::raiseError(500, $row->getError() ); } $row->quicktake = JRequest::getVar( 'quicktake', '', 'post', 'string', JREQUEST_ALLOWRAW ); $row->review = JRequest::getVar( 'review', '', 'post', 'string', JREQUEST_ALLOWRAW ); if(!$row->review_date) { $row->review_date = date( 'Y-m-d H:i:s' ); } if (!$row->store()) { JError::raiseError(500, $row->getError() ); } $mainframe->redirect('index.php?option=' . $option, 'Review Saved'); }
Let's look at what this code is doing. First, JRequest::checkToken()
determines whether a token has been passed in for...