the code i have at the minute makes it so that i can retrive the entries and diplay each one in a text field this will allow me to edit any comments then i will beable to save the changes or just delete an enry altogether
i need to know how to delete an etry altogether from the text file and save the edited comments
the code for my admin section at the minute is
Code: Select all
//admin user name and admin password
$adminUserName = 'admin';
$adminPass = 'password';
//form elements for admin login
$adminUser = $_POST['user'];
$adminPass = $_POST['pass'];
//check to see if passwords match
if ($adminUser == $adminUserName && $adminPass == $adminPass){
echo ("You are now logged in as admin");
$txtFile = "g.txt";
$filepointer = fopen($txtFile, "a+")
or die("txt file missing");
$data = fread($filepointer, filesize($txtFile));
$a_post=explode(";",$data);
$number=count($a_post)-1;
print("<div id='entry'>");
for ($i=($number-1);$i>=0;$i--){
$a_element=explode("|",$a_post[$i]);
print ("Post No: " . ($i+1) . " on the " . $a_element[0] . "<br/>" . "Posted by " ."<input type='text' value='". $a_element[1] . "'> they said:<br/><em>" ."<input type='text' value='". $a_element[3] . "'></em><br/><br/>" . $a_element[1] . "'s url: ".$a_element[2] . "<hr/>");
print("<div id='submitButton'>");
print("<input name='delete' type='button' value='Delete'/>");
print("<input name='save' type='button' value='Save'/>");
print ("</div>");
}
print("</div>");
}else{
die ("Your username/password is not correct");
}