Fw: array transfer via form.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



1. i have a txt file with data 
    like this: LINE 1-->  12345678890
                 LINE 2-->  abcdefghglld
                 LINE 3-->  asdfg
                 .
                 .
                 .
                 LINE X --> bla-bla-bla
2. then i view this txt file in a browser with a <input type="text" value="<?php echo $myline; ?>">

    in my browser it looks like this:
  
  
  
 

3. now i want to edit this txt file here in my browser using this form..

4. how can i create a file that will write the changes i made in this form? i did write the file but i get only 1 line (asdfg) the last array..

5. heres my code checkbox.php
<body>
<form name="form1" method="post" action="check_act.php">
<?php
          $rory = file("/var/lib/data/access.temp.txt", "r");
          //get number of lines
          $number_of_lines = count($rory);
              if ($number_of_lines == 0) { echo "<p><strong>No record found please try again later.</strong></p>"; }
              for ($i=0; $i<$number_of_lines; $i++)
              {
                  $myinfo = $rory[$i];
                  $myline = substr($myinfo,0,-1);
?>
<input name="myline" type="text" size="125" value="<?php echo $myline; ?>">
<br>
<?php } ?> 
  <input type="submit" name="Submit" value="Submit">
</form>

6. heres the action page check_act.php
<?php
$file2write = fopen("/var/lib/data/access.temp2.txt", "w");
$write2line = "$myline\n";
$filewrite = fwrite($file2write, $write2line); 
?>

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux