dynamic_delete_form_php

    1| <?php
    2|     session_start();
    3| 
    4|     //Read in the external functions file
    5|     require("dynamic_routines.php");
    6| 
    7|     $list_one = $_SESSION['fileid'];
    8|     $file_passed_tests = true;
    9| 
  10|     //Does the file exist?
  11|     if(!file_lives($list_one))
  12|     {
  13|         $file_passed_tests = false;
  14|     }
  15|     else
  16|     {
  17|         //Can the file be read?
  18|         if(!file_is_readable($list_one))
  19|         {
  20|             $file_passed_tests = false;
  21|         }
  22|     }
  23| 
  24| ?>
  25| 
  26| <html>
  27| <head>
  28|     <title>Dynamic Web Page Delete Form</title>
  29| </head>
  30| <body>
  31| <h1>Dynamic Web Page Delete Form</h1>
  32| 
  33| <form name="delete_form" action="http://localhost/phpwork/week6/dynamic_delete.php" method="post">
  34| <fieldset>
  35|     <p>Select a record to be deleted:</p>
  36| 
  37| <?php
  38|     $all_records = array();
  39| 
  40|     //Open the file for reading only
  41|     $fHandle = open_a_file($list_one, "r");
  42| 
  43|     //Did the file open
  44|     if($fHandle)
  45|     {
  46|         //Read records into an array
  47|         $all_records = read_file_by_record($fHandle);
  48|         close_a_file($fHandle);
  49| 
  50|         //Select only valid records
  51|         $all_records = validate_records($all_records, 9, "|", 9);
  52| 
  53|         //Strip off sort data and bar (a.k.a. "|")
  54|         $all_records = retrieve_data_only($all_records, "|", 1);
  55| 
  56|         $count_records = count($all_records);
  57| 
  58|         //display the events
  59|         if($count_records > 0)
  60|         {
  61|             for($x = 0; $x < $count_records; ++$x)
  62|             {
  63|                 //Extract next record
  64|                 $record = $all_records[$x];
  65| 
  66|                 echo "<input type=\"radio\" name=\"record_number\" id=\"record_number\" value=\"".$x."\" />";
  67|                 echo $record."<br>";
  68|             }
  69|         }
  70|         else
  71|         {
  72|             echo "No events at this time.";
  73|         }
  74|     }
  75| ?>
  76| 
  77|     <br><br>
  78|     <input type="submit" name="submit" value="Delete record" /><br>
  79|     <input type="reset" name="reset" value="Reset" />
  80| </fieldset>
  81| </form>
  82| </body>
  83| </html>