dynamic_delete_php
1| <?php
2| session_start();
3|
4| $message = "";
5| $fileid = $_SESSION['fileid'];
6| $record_number = $_POST['record_number'];
7|
8| //Read in the external functions file
9| require("dynamic_routines.php");
10|
11| //verify user is logged in
12| if(!$_SESSION['logged_in'])
13| {
14| $Msg = "You must first login before you can delete a record.";
15| error_page("Validation Error", $Msg);
16| exit();
17| }
18|
19| //validate selection
20| if(empty($record_number))
21| {
22| if($record_number != 0)
23| {
24| $msg .= "You must select a record to delete.<br>";
25| error_page("Input Error", $msg);
26| exit();
27| }
28| }
29|
30| $all_records = array();
31|
32| //Open the file for reading only
33| $fHandle = open_a_file($fileid, "r");
34|
35| //Did the file open
36| if($fHandle)
37| {
38| //Read records into an array
39| $all_records = read_file_by_record($fHandle);
40| close_a_file($fHandle);
41| }
42|
43| //Delete the record
44| $deleted = rewrite_delete_data_file($fileid, $all_records, $record_number);
45|
46| if(!$deleted)
47| {
48| $msg .= "Your selected record was not delete.<br>";
49| error_page("Input Error", $msg);
50| exit();
51| }
52|
53| page_selection();
54|
55| ?>