Can anyone can help me with this routine. It's probably embarrassingly simple but I'm not very far ahead with PHP, so I would appreciate some help.
I have a flat-file database, which contains a record of titles for pictures. Its lines are like:
1|This is a caption for a picture|
2|This is another caption for a picture|
3|This is yet another caption for a picture|
...and so-on. I'm trying to write some PHP code which will allow a user to change those caption titles in the database. So, I'm trying a form, which takes the number of the caption to be changed, and the new text for the caption, like this:
<form id="catmanageform" action="processcatalogue1.php" method="post">
Enter Picture Number to change:<br />
<input type="text" name="picnumbertochange" size="3" maxlength="3">
<br /><br />
Enter New Text Description:<br />
<input type="text" name="pictexttochange" size="50" maxlength="50">
<br /><br />
<input type="submit" name="proccat1Button" value="Submit New Values">
</form>
This sends to "processcatalogue1.php", and it's here that I'm getting stuck.
So far I have:
<?php
$CurrentPicNumber = $POST['picnumbertochange'];
$CurrentPicNewText = $POST['pictexttochange'];
$Database = fopen('/...serverpath.../database.txt', "w");
...Now I want to read the Database in, insert the new values for the caption from the form, and then write it out again (overwrite it). I've done this before where the HTML form actually included all the values of the database, so in that case was easy: the user just changed selected values from all the values, as required, clicked send, and so the whole 'new' database was read in, and then written back. But here I was hoping to do it by only changing the single selected "number and text" pair. But I'm conceptually flummoxed! Can anyone help?