How can I unset a line in PHP after pressing a submit button?
<p>I have this code now, but whenever I get to the page my entire text.txt file gets deleted. I am using sessions to get the information from a page from another php document. This is the 3rd page it directs to after information is input.</p>

<p>I would like choose which line to delete from the text file from an input form, but I cannot seem to get it working. Any suggestions? thanks</p>

<pre><code>&lt;?php 
$tekstFil = fopen("test.txt","r");
$t = 0;
while (!feof($tekstFil)) {

  $informasjonLinje = fgets ($tekstFil);

  echo "$t : $informasjonLinje &lt;br/&gt;";

  $t++;
}

fclose($tekstFil);

$fil = file("test.txt");

echo "&lt;br/&gt;";

echo "&lt;form action='' type='get'&gt;";
  echo "Velg hvilken linje med informasjon du vil slette: ";
  echo "&lt;input type='number' name='linjeNummer' value=''&gt;";
  echo "&lt;input type='submit' name='slett' value='slett'&gt;";
echo "&lt;/form&gt;";

if(isset($_GET["slett"])) {
  echo "Du valgte å slette linje nummer: " .  $_GET["linjeNummer"];
}

$linjeNummer = $_GET["linjeNummer"];

  unset($fil[4]);

$fil = array_values($Fil);
$tekstFil = fopen("test.txt", "w");

foreach ($fil as $verdi) {
  fwrite($tekstFil, $verdi);
}
fclose($tekstFil);
</code></pre>