Could someone help me with a problem I'm having with my guestbook, I'm stuck on getting the variable name "uid" (Unique Identifier) from admin.php into delete.php to allow me to delete a post from my textfile.
Btw I had the guestbook working and deleting posts last nite, unfortunately I stuffed it up adding a swearfilter :bemused:
Also the 'uid' saves the whole entry not just a part of the array.
Admin.php
<?php
$file = "gb.txt";
$open = fopen($file, "r")
or die("txt file missing");
$size = filesize($file);
$fstring = fread($open,filesize($file)+1);
?>
</head>
<body>
<?php
$line = explode("&.&",$fstring);
foreach($line as $var)
{
if ($var != null) {
$elements = explode("|",$var);
print("<div id='entry'>");
print("Date: ".$elements[1] . "<br/>" . "Name: ".$elements[2] . "<br/>" . "Email: ".$elements[3] . "<br/>" . "Comment: ".$elements[4] . "<br/>" . "
<a href =delete.php? uid=".$var.">Delete Entry</a>" ); //<----------Problem here?
print("</div>");
}
}
?>
<form name=test action="lookgb.php">
<input type="hidden" name=changeval value=0>
<input type="hidden" name=so value=asc>
</form>
</td></tr>
<tr height=70 align=center><td align=center background="images/bg2.gif">
<a href="index.php"><font color=#332266>Sign My Guest Book</font></a><br>
<br>
<div align=right>
<script language="javascript">document.onload = che();</script>
</div>
</td></tr>
</body>
</html>
delete.php
<?php
$uid = $_GET['var']; // <-------------- possible problem?
$file = "gb.txt";
$open = fopen($file,'r+');
$fstring = fread($open,filesize($file)+1);
?>
</head>
<body>
<?php
$line = explode("&.&",$fstring);
$newarray = array();
$x=0;
foreach($line as $var) {
if ($uid!=$var){
$newarray=array(x=>$var);
$x=$x+1;
}
}
$line=null;
$line=$newarray;
?>
<a href="admin.php"><font color=#332266>Back to Admin</font></a><br>
</body>
</html>
-----------------------------------------------------------------------------------------
Thanks for any help. 🙂 much appreciated!
Ben.