Topic: returning the values

i have the code

<?php 


$dir = "./lists";
// process form submission, all pass hidden variable "name"
if ($_POST["name"]) {
  $name = trim($_POST["name"]);
  // ID and NAME tokens must begin with a letter ([A-Za-z]) 
  // and may be followed by any number of letters, digits ([0-9]), 
  // hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
  $idtoken = str_replace(" ", "-", $name);
  // User names must start with a letter, and may contain only letters, numbers or spaces
  if (preg_match("/^[a-zA-Z][a-zA-Z0-9\ ]*$/", $name)) {
    $filename = $dir . "./lists/" . $name . ".lst";
    // add item to list, if submitted
    if ($_POST["item"]) {
      // disable all HTML and remove surrounding whitespace
      $item = htmlentities(trim($_POST["item"])) . "\n";
      // file exists and is writable?
      if (is_writable($filename)) {
        // open file in append mode
        if (!$fp = fopen($filename, 'a')) {
          print "Cannot open file ($filename)";
          exit;
        } else {
          // Add item to list.
          if (!fwrite($fp, $item)) {
            print "Cannot write to file ($filename)";
            exit;
          }
          fclose($fp);
        }
      } else {
        print "The file $filename is not writable";
        exit;
      }
    // write edited list, if submitted
    } elseif ($_POST["newlist"]) {
      // escape HTML & make sure list ends with a line feed, or it might not write to file properly
      $list = htmlentities(trim($_POST["newlist"])) . "\n";
      // file exists and is writable?
      if (is_writable($filename)) {
        // Open $filename in write mode, to replace contents.
        if (!$fp = fopen($filename, 'w')) {
          print "Cannot open file ($filename)";
          exit;
        }
        // Write new list to our opened file.
        if (!fwrite($fp, $list)) {
          print "Cannot write to file ($filename)";
          exit;
        }
        fclose($fp);
      } else {
        print "The file $filename is not writable";
        exit;
      }
    // add new user, if submitted
    } elseif ($_POST["addname"]) {
      // Does file already exist?
      if (is_file($filename)) {
        print $name . " already exists.";
        exit;
      } else {
        // create empty list file for $name by opening it in write mode
        $fp = fopen($filename, 'w');
        fclose($fp);
      }
    }
    // all form submissions should take us back to the user's list
    $redir = "#" . $idtoken;
    Header("Location:admin_loader.php?plugin=AMP_Awards1.php" . $redir);
  } else {
    // illegal name was submitted
    print "Names must start with a letter or number, and contain only letters, numbers or spaces.";
    exit;
  }
} else {
    print "nOBODY HERE BUT US CHICKENS!";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
<h1>Awards</h1>
<hr>

<?php


//path of lists directory, absolute or relative to this script
$listdir = "./lists/";
//chdir($listdir);
//get list names
$lists = glob("*.lst");
foreach ($lists as $list) {
  $name = preg_replace("./.lst$/", "", $list);
  $idtoken = str_replace(" ", "-", $name);
  $xmaslist = stripslashes(trim(file_get_contents($list)));
  // create list heading, with named anchor
  // note that named anchors with spaces are legal, but not recognized by all browsers
  print <<<EOD
<!-- List for $name starts here -->
<div class="xmaslist">
<h2 id="$idtoken">$name</h2>
<blockquote>
<pre>
$xmaslist
</pre>
<form action="admin_loader.php?plugin=AMP_Awards1.php" method="POST">
1
<p><input type="text" name="item" size="32" maxlength="72">
<input type="hidden" name="name" value="$name">
<input type="submit" value="Add item to list"></p>
</form>
<form action="edit1.php" method="POST">
<p><input type="hidden" name="name" value="$name">
<input type="submit" value="Edit $name's list"></p>
</form>
</blockquote>
</div>
<!-- List for $name ends here -->
EOD;
}

?>
<form action="admin_loader.php?plugin=AMP_Awards1.php" method="POST">
2
<p style="margin-top: 3em;"><strong>Missing?</strong> <br>
Add your name <em>(letters, numbers and spaces only)</em>:<br>
<input type="text" name="name" size="32" maxlength="64">
<input type="submit" name="addname" value="Add Name"></p>
</form>
</body>
</html>

and i am trying to put it in to a admin page but am unable to fetch the results

im making a plug in, using a form in a plug in, but am having problems when returning the values? any one able to help?

Sorry. Unactive due to personal life.

Re: returning the values

Just incase you rename the file:

<form blah action="<?php echo $_SERVER['REQUEST_URI'] ?>">
$filename = $dir . "./lists/" . $name . ".lst"; // $filename = "./lists./lists/".$name.".lst" remove that static "./lists/" :P
//path of lists directory, absolute or relative to this script
$listdir = "./lists/";
//chdir($listdir);
//get list names
$lists = glob("*.lst"); // Maybe you want glob($listdir."*.lst")
  $name = preg_replace("./.lst$/", "", $list); // try preg_replace('/^(.*)\.lst$/', '${1}', $list)

And

print_r($_POST);
exit();

is great for debugging forms big_smile

echo "deadram"; echo; fortune;