Thank you very much.. I have one more question, if you don't mind.
I wanted to make a table that shows the information somebody entered.. and then I wanted to add a link for editing the specific row in the table... the key that i used to find that specific row in the table is the email that was entered first..
The problem is, that when I klick on the edit link, I have to change all the rows, first the one i wanted and then all the others in the table, and after that from the beginnig. It seems to me like an endless loop(??). Here is the code.. maybe somebody can help me.
<?php
echo 'The row we are searching for: ', $_GET['r']; //it gets us the row in the table that includes the email that we are searching for
// and that we use as a searching key
$dat=file($path);
foreach($dat as $row)
{
$information=explode("\t",$row);
if(trim($information[2])==($_GET['r'])) // we found row with the email we are looking for
{
foreach($information as $array) {echo $array, '-'; }
break;
}
}
?>
<form name="form1" method="post" action="">
<p>
<label>Name
<input name="name" type="text" id="name" value= "<?php echo $information[0]; ?>">
</label>
</p>
<p>
<label>Surname
<input name="surname" type="text" id="surname" <?php echo $information[1]; ?>">
</label>
</p>
<p>
<label>Email
<input name="email" type="text" id="email" <?php echo $information[2]; ?>">
</label>
</p>
<p>
<label>
<input type="submit" name="Submit" value="Submit">
</label>
</p>
<p>
<label>
<input name="email_old" type="hidden" id="email_old" value="<?php echo $information[2]; ?>">
</label>
</p>
</form>
<?php
if($_POST)
{
$name=$_POST['name'];
$surname=$_POST['surname'];
$email=$_POST['email'];
$email_old=$_POST['email_old'];
$f=fopen($path,'r');
flock($f,LOCK_EX);
$all='';
while(!feof($f))
{
$row=fgets($f,1300);
$arrays=explode("\t",$row);
if(trim($arrays[2])==$email_old) //we search for the row in our table with the old email
//if we find it, we can change the values we entered before
{
$arrays[0]=$name;
$arrays[1]=$surname;
$arrays[2]=$email;
}
$row=implode("\t",$arrays);
$row=$row."\n";
$all=$all.$row;
}
flock($f,LOCK_UN);
fclose($f);
$f=fopen($path,'w');
flock($f,LOCK_EX);
fwrite($f,$all,strlen(rtrim($all)));
flock($f,LOCK_UN);
fclose($f);
}
?>