tagging as ATutor 1.5.4-release
[atutor.git] / faq / add_topic.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2006 by Greg Gay & Joel Kronenberg        */
6 /* Adaptive Technology Resource Centre / University of Toronto  */
7 /* http://atutor.ca                                                                                             */
8 /*                                                              */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License  */
11 /* as published by the Free Software Foundation.                                */
12 /****************************************************************/
13 // $Id$
14 define('AT_INCLUDE_PATH', '../include/');
15 require (AT_INCLUDE_PATH.'vitals.inc.php');
16
17 authenticate(AT_PRIV_FAQ);
18
19 if (isset($_POST['cancel'])) {
20         $msg->addFeedback('CANCELLED');
21         header('Location: index_instructor.php');
22         exit;
23 } else if (isset($_POST['submit'])) {
24         if (trim($_POST['name']) == '') {
25                 $msg->addError('NAME_EMPTY');
26         }
27
28         if (!$msg->containsErrors()) {
29                 $_POST['name'] = $addslashes($_POST['name']);
30
31                 $sql    = "INSERT INTO ".TABLE_PREFIX."faq_topics VALUES (NULL, $_SESSION[course_id], '$_POST[name]')";
32                 $result = mysql_query($sql,$db);
33                 
34                 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
35                 header('Location: index_instructor.php');
36                 exit;
37         }
38 }
39
40 $onload = 'document.form.name.focus();';
41
42 require(AT_INCLUDE_PATH.'header.inc.php');
43
44 ?>
45
46 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
47
48 <div class="input-form">        
49         <div class="row">
50                 <div class="required" title="<?php echo _AT('required_field'); ?>">*</div><label for="name"><?php  echo _AT('name'); ?></label><br />
51                 <input type="text" name="name" size="50" id="name" value="<?php if (isset($_POST['name'])) echo $stripslashes($_POST['name']);  ?>" />
52         </div>
53
54         <div class="row buttons">
55                 <input type="submit" name="submit" value="<?php echo _AT('save'); ?>" accesskey="s" />
56                 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
57         </div>
58 </div>
59 </form>
60
61 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>