} else { $message = "Updated record for '" . $title . "' id=" . $idvalue; $action = 'main'; } } else { $sql = 'INSERT INTO ads ' . '( title, description, course_key, user_key, user_name, user_image, created_at, updated_at ) ' . ' VALUES ( ' . "'" . mysql_real_escape_string($title) . "', " . "'" . mysql_real_escape_string($description) . "', " . "'" . mysql_real_escape_string($context->getCourseKey()) . "', " . "'" . mysql_real_escape_string($context->getUserKey()) . "', " . "'" . mysql_real_escape_string($context->getUserName()) . "', " . "'" . mysql_real_escape_string($context->getUserImage()) . "', " . " NOW(), NOW() ) "; $result = mysql_query($sql); $retval = mysql_affected_rows(); if ($retval != 1) { $message = "Error, unable to insert ad."; $action = 'add'; } else { $idvalue = mysql_insert_id(); $message = "Inserted ad '" . $name . "' id=" . $idvalue; $action = 'main'; $context->redirect(); } } } else { $message = "Error, please specify all data."; $action = 'add'; if ($idvalue) { $action = 'edit'; } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head>