dynamic_add_php

  1| <?php
  2|     session_start();
  3| ?>
  4| <?php
  5| 
  6|     $content = $_POST['content'];
  7|     $sortkey = $_POST['sortkey'];
  8|     $message = "";
  9|     $error_sw = false;
10| 
11|     //bring in reusable routines
12|     require("dynamic_routines.php");
13| 
14|     //Verify the user logged in
15|     if(!$_SESSION['logged_in'])
16|     {
17|         $Message = "You must first login before you can add records";
18|         error_page("Validation Error", $Message);
19|         exit();
20|     }
21| 
22|     //validate content
23|     if(empty($content))
24|     {
25|         $message .="You must enter record data.<br />";
26|         $error_sw = true;
27|     }
28| 
29|     //validate sort key
30|     if(empty($sortkey))
31|     {
32|         $message .="You must enter a sort key.<br />";
33|         $error_sw = true;
34|     }
35|     else
36|     {
37|         if (strlen($sortkey) != 8)
38|         {
39|             $message .="Your sort key must be 8 characters long.<br />";
40|             $error_sw = true;
41|         }
42|     }
43| 
44|     if($error_sw)
45|     {
46|         error_page("Input Errors", $message);
47|         exit();
48|     }
49| 
50|     //We have good data
51| 
52| ?>
53| 
54| <?php
55|     //Good Data
56|     if(!add_record_to_file($sortkey, $content, $_SESSION['fileid'], "|"))
57|     {
58|         //not added
59|         $message = "Record not added.";
60|         error_page("Record Add Error",$message);
61|         exit();
62|     }
63| 
64|     page_selection();
65| ?>