akimm Posted September 26, 2006 Share Posted September 26, 2006 This file is meant to glob() my entrys directory, and pull all txt extension files into a foreach loop, which will then be printed with a yes or no below them. The yes means I approve the file and want it to be written to the server in guestbook.txt which can then be used as my guestbook entry file, after its written I want it unlinked anyway because it will be written to a new fie. If i click no, I want the file to be unlinked immediately.approve.php[code]<?phpforeach (glob("entrys/*.txt") as $files) { ?><table><form method="POST" action="ad.php"><tr><td><?php include($files);?></td></tr> <tr><td><h2>yes</h2></td><br><td><input type="radio" name="name" value="yes" id="yes"><label for="yes">Yes</label></td></tr><tr><td><h2>no</h2></td><br><td><input type="radio" name="name" value="no" id="no"><label for="no">No</label><</td></tr> <?php echo "</table>"; }?><input type="submit" value="submit for addition to guestbook" name="guestbook"></form>[/code][code]ad.php<?php$fp = fopen('guestbook.txt', 'w');if($_POST['name'] == "yes" && $fp) {fwrite($fp, $files);fclose($fp);unlink($_POST['name']); }if($_POST['name'] == "no") {unlink($_POST['name']);}?>[/code]I appreciate any assistance, thanks in advance. Quote Link to comment Share on other sites More sharing options...
Jocka Posted September 26, 2006 Share Posted September 26, 2006 it might work better if you put the file information in the form hidden.<input type='hidden' name='files' value='<? echo $files; ?>'>Then on ad.php change to this:[code]<?php$files = $_POST['files'];$fp = fopen('guestbook.txt', 'w');if($_POST['name'] == "yes" && $fp) {fwrite($fp, $files);fclose($fp);unlink($files); }if($_POST['name'] == "no") {unlink($files);}?>[/code] Quote Link to comment Share on other sites More sharing options...
akimm Posted September 27, 2006 Author Share Posted September 27, 2006 Thank you Jocka, I will give that a try. I appreciate your help ;D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.