title: textfile update, add and delete
body: <p>Ok i have this code:</p>
  
  <pre><code>&lt;?php
  
  //this is the thispage.php
  
  $file = "data.txt";
  $name = $_POST['name'];
  $url = $_POST['url'];
  
  $data = file('data.txt');
  $i = 1;
  foreach ($data as $line) {
  $line = explode('|', $line);
  $i++;
  }
  
  if (isset($_POST['submits'])) {
  $fp = fopen($file, "a+");
  fwrite($fp, $i."|".$name."|".$url."|\n");
  fclose($fp);
  }
  
  
  ?&gt;
  </code></pre>
  
  <p>and this index.php.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;br&gt;
  &lt;form name="form1" action="thispage.php" method="POST"&gt;
  &lt;input type="text" name="name"&gt;
  &lt;input type="text" name="url"&gt;
  &lt;input type="submit" name="submits" value="ADD"&gt;&lt;br&gt;
  &lt;/form&gt;
  &lt;form name="form2" action="thispage.php" method="POST"&gt;
  &lt;?php
  
  $display = file("data.txt");
     for ($i=0; $i&lt;=count($display)-1; $i++) {
     $lines = explode("|",$display[$i]);
  
     print('&lt;input type="hidden" name="id" value="'.$lines[0].'"&gt;
               &lt;input type="text" name="name" value="'.$lines[1].'"&gt;
               &lt;input type="text" name="url" value="'.$lines[2].'"&gt;
               &lt;input type="submit" name="update" value="UPDATE"&gt;
               &lt;input type="submit" name="delete" value="DELETE"&gt;&lt;br&gt;');
     }
  
  ?&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and this is the data.txt contains.</p>
  
  <pre><code>1|John|http://www.john.com|
  2|Mark|http://www.mark.com|
  3|Fred|http://www.fred.com|
  4|Johnxxx|asdasdasdasd|
  </code></pre>
  
  <p>Im having a hard time, making this one works, trying to update and delete, I can add but I cant update and delete either. hope you guys can help me, this is a expirement. thank you in advance.</p>