Posted: Tue Sep 26, 2006 11:05 pm
Ok Thank You I'm adding it now
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
<?php
// First check if any form being posted to this page. //
if(!isset($_POST)){
$fp = fopen('guestbook.txt', 'a');
// Start to do something if the file open sucessful. //
if($fp){
foreach($_POST['yes'] as $filename){ //<-- Loop through all approved files.
fwrite($fp, $filename);
}
fclose($fp); //<-- Since the file write is completed, close file.
// Remove files which is not approved. //
foreach($_POST['no'] as $filename) {
$check_del = unlink($filename);
echo $check_del;
}
}
}
?>Code: Select all
<?php
foreach (glob("entrys/*.txt") as $files) {
?>
<table>
<form method="POST" action="ad1.php">
<tr><td><?php include($files);?></td></tr>
<tr><td><h2>yes</h2></td><td><input type="radio" name="yes[]" value="<?php echo $files; ?>" id="yes"></td></tr>
<tr><td><h2>no</h2></td><td><input type="radio" name="no[]" value="<?php echo $files; ?>" id="no"></td></tr>
<input type="submit" value="submit for addition to guestbook" name="guestbook">
</form>
</table>
<?php
}
?>Code: Select all
<?php
// First check if any form being posted to this page. //
if(!isset($_POST)){
$fp = fopen('guestbook.txt', 'a');
// Start to do something if the file open sucessful. //
if($fp){
foreach($_POST['yes'] as $filename) //<-- Loop through all approved files.
fwrite($fp, $filename);
}
fclose($fp); //<-- Since the file write is completed, close file.
// Remove files which is not approved. //
foreach($_POST['no'] as $filename) {
$check_del = unlink($filename);
echo $check_del;
}
}
?>Code: Select all
<table>
<form method="POST" action="ad1.php">
<?php
foreach (glob("txt/*.txt") as $files) {
?>
<tr><td><?php include($files);?></td></tr>
<tr><td><h2>yes</h2></td><td><input type="radio" name="yes[]" value="<?php echo $files; ?>" id="yes"></td></tr>
<tr><td><h2>no</h2></td><td><input type="radio" name="no[]" value="<?php echo $files; ?>" id="no"></td></tr>
<?php
}
?>
<input type="submit" value="submit for addition to guestbook" name="guestbook">
</form>
</table>Code: Select all
<?php
// First check if any form being posted to this page. //
if(isset($_POST)){
$fp = fopen('openfile.txt', 'a');
// Start to do something if the file open sucessful. //
if($fp){
foreach($_POST['yes'] as $filename) //<-- Loop through all approved files.
fwrite($fp, $filename);
}
fclose($fp); //<-- Since the file write is completed, close file.
// Remove files which is not approved. //
foreach($_POST['no'] as $filename) {
$check_del = unlink($filename);
echo $check_del;
}
}
?>Code: Select all
<table>
<form method="POST" action="<?php $_SERVER['PHP_SELF']; ?>">
<?php
foreach (glob("entrys/*.txt") as $files) {
?>
<tr><td><?php include($files);?></td></tr>
<tr><td><h2>yes</h2></td><td><input type="radio" name="yes[]" value="<?php echo $files; ?>" id="yes"></td></tr>
<tr><td><h2>no</h2></td><td><input type="radio" name="no[]" value="<?php echo $files; ?>" id="no"></td></tr>
<?php
}
?>
<input type="submit" value="submit for addition to guestbook" name="guestbook">
</form>
</table>
<?php
// establish all variables needed
$yes = $_POST['yes'];
$no = $_POST['no'];
$fp = fopen('guestbook.txt', 'a');
$check_del = unlink($files);
$approved = include($files);
// set an array for POST values
$check = array(
$_POST['name'] => "yes",
$_POST['name'] => "no",
$_POST['name'] => ""
);
//if that array is working, while its an instance of yes, fwrite the contents, of $files to the guestbook.txt
if(is_array($check)) {
while($yes) {
if ($fp) {
fwrite($fp, $approved);
$check_del;
// break the array of course
break;
}
fclose($fp);
}
}
// ditto, only for no.
if(is_array($check)) {
while($no) {
$check_del;
// break the array
break;
fclose($fp);
}
}
?>Code: Select all
<?php
// establish all variables needed
foreach (glob("entrys/*.txt") as $files) {
}
$yes = $_POST['yes'];
$no = $_POST['no'];
$fp = fopen('guestbook.txt', 'a');
$check_del = unlink($files);
$approved = include($files);
// set an array for POST values
$check = array(
$_POST['name'] => "yes",
$_POST['name'] => "no",
$_POST['name'] => ""
);
//if that array is working, while its an instance of yes, fwrite the contents, of $files to the guestbook.txt
if(is_array($check)) {
foreach($yes as $value) {
if ($value) {
fwrite($fp, $approved);
$check_del;
// break the array of course
break;
}
fclose($fp);
}
}
// ditto, only for no.
if(is_array($check)) {
if(!$value) {
$check_del;
// break the array
break;
}
fclose($fp);
}
?>Code: Select all
<table>
<form method="POST" action="ad1.php">
<?php
foreach (glob("entrys/*.txt") as $files) {
?>
<tr><td><?php include($files);?></td></tr>
<tr><td><h2>yes</h2></td><td><input type="radio" name="yes[]" value="<?php echo $files; ?>" id="yes"></td></tr>
<tr><td><h2>no</h2></td><td><input type="radio" name="no[]" value="<?php echo $files; ?>" id="no"></td></tr>
<?php
}
?>
<input type="submit" value="submit for addition to guestbook" name="guestbook">
</form>
</table>Code: Select all
<table>
<form method="POST" action="<?php $_SERVER['PHP_SELF'];?>">
<?php
foreach (glob("entrys/*.txt") as $files) {
?>
<tr><td><?php include($files);?></td></tr>
<tr><td><?php echo printit(); ?></td></tr>
<tr><td><h2>yes</h2></td><td><input type="radio" name="yes[0]" value="<?php echo $files; ?>" id="yes"></td></tr>
<tr><td><h2>no</h2></td><td><input type="radio" name="no[1]" value="<?php echo $files; ?>" id="no"></td></tr>
<?php
}
?>
<input type="submit" value="submit for addition to guestbook" name="guestbook">
</form>
</table>
<?php
function printit(){
foreach (glob("entrys/*.txt") as $files) {
return print_r($files);
}
}
function delete_it () {
foreach (glob("entrys/*.txt") as $files) {
if($no) {
unlink($files);
fclose($fp);
}
}
return delete_it;
}
?>
<?php
## variables ################################
$yes = $_POST['yes']; #
$no = $_POST['no']; #
$fp = fopen('guestbook.txt','a'); #
$confirmation = "It worked stupid"; #
$delete_it = delete_it(); #
$print_it = printit(); #
$write_format = $print_it . "<br>" . $files;#
#############################################
if($yes) {
fwrite($fp, $files);
$delete_it;
} else {
$delete_it;
}
fclose($fp);
?>Code: Select all
<?php
foreach (glob("entrys/*.txt") as $files) {
// establish all variables needed
$yes = $_POST['yes'];
$no = $_POST['no'];
$fp = fopen('guestbook.txt', 'a');
$check_del = unlink($files);
$approved = include($files);
// set an array for POST values
$check = array(
$yes => "yes",
$no => "no"
);
// $approved is the info that is included, the guests actual entry
foreach($approved as $key => $content) {
//if $check is an array then do foreach
if(is_array($check)) {
//$yespost is equivalent to $_POST['yes']
foreach($yes as $id => $yespost) {
if ($yespost) {
fwrite($fp, $content);
$check_del;
}
fclose($fp);
}
}
// ditto, only for no. and if !$yespost is $_POST['no'] then delete file
if(is_array($check) && !yespost) {
$check_del;
}
fclose($fp);
}
}
?>