Here is my first attempt at this. I would like to echo the array info so I don't have to type this a ton of times but I'm not sure how to do it.

<input type="hidden" value="<?php echo "$whatever"; ?>" name="whatever">

<?php
if (isset($HTTP_POST_VARS['cfileaction'])) {
$cfileaction=$HTTP_POST_VARS['cfileaction'];
}
if (isset($HTTP_POST_VARS['fname'])) {
$fname=$HTTP_POST_VARS['fname'];
}
if (!isset($cfileaction)) {
$cfileaction="0";
}
if (($cfileaction!="form")and($cfileaction!="verify")and($cfileaction!="cfile"))   {
$cfileaction="form";
}

if (($cfileaction=="verify")and(!$fname)) {
$cfileaction="form";
}

if (($cfileaction=="cfile")and(!$fname)) {
$cfileaction="form";
}

if (($cfileaction=="verify")and(file_exists($fname))) {
$cfileaction="form";
}

if (($cfileaction=="cfile")and(file_exists($fname))) {
$cfileaction="form";
}

if ($cfileaction=="form") {
?>

<hr width="70%" align="center">
<div class="subadmintitle" align="left">Enter File Name</div><br>
<div align="justify" class="admintext">
Please enter a file that does not exist or you will get nothing.<br>
<form method="POST" action="cfile.php">
<div class="admintext">Enter File Name</div>
<input type="text" value="" name="fname"><br>
<?php
[B]$Ffields = array("Name", "Address", "Etc");
foreach ($Ffields as $Ffield) { 
   print '<input type="text" name="' . $Ffield .'" value="';
     print htmlentities($Ffield[$Ffields]) . '">';
}[/B]?>
<input type="text" value="" name="fc"><br>
<input type="hidden" value="verify" name="cfileaction"><br>
<input type="submit" value="Create">
</form>
</div>

<?php
} elseif ($cfileaction=="verify") {
?>

<hr width="70%" align="center">
<div class="subadmintitle" align="left">Create A File :: Please Verify</div><br>
<div class="admintext" align="left">You have entered the file name <?php echo"$fname"; ?>
<form method="POST" action="cfile.php">
<input type="hidden" value="<?php echo"$fname"; ?>" name="fname">
<input type="hidden" value="<?php echo "$Name"; ?>" name="Name">
<input type="hidden" value="<?php echo "$Address"; ?>" name="Address">
<input type="hidden" value="cfile" name="cfileaction">
<input type="submit" value="Continue?">
</form>
<form method="POST" action="cfile.php">
<input type="hidden" value="form" name="cfileaction">
<input type="submit" value="Go Back?">
</form>
</div>

<?php
} elseif ($cfileaction=="cfile") {

//This is in here for future purpose
$fc= htmlspecialchars($fc);

//Create file and add initial content
$fp = fopen($fname,"w"); 
fwrite($fp,$Name,Address); 
fclose($fp);

//Check that the file has been created and send out message
if (file_exists($fname)) {
?>

<hr width="70%" align="center">
<div class="subadmintitle" align="left">Congratulations</div><br>
<div class="admintext" align="justify">
<?php echo "Congratulations <a href=\"$fname\">$fname</a> has been created."; ?> You may now go to your file!<br><br>
<form method="POST" action="cfile.php">
<input type="hidden" value="form" name="cfileaction">
<input type="submit" value="Create Another File">
</form>
</div>

<?php
chmod($fname,0755);

} else {
?>

    i think you are going for something along the lines of...

    $Ffields = array('Name', 'Address', 'Etc');
    
    //later on
    
    foreach($Ffields as $Ffield) {
      echo "<input type=\"text\" name=\"$Ffield\" value=\"" . (isset($_POST[$Ffield])) ? htmlentities($_POST[$Ffield]) : '' . "\" />\n";
    }
    

      It does the foreach in the form but doesn't carry the values to the page that's created once posted. I get an empty page did I forget something?

      Where was I supposed to put that?

      Thanks for your help. This is the first time anyone answered one of my questions!

        oh well i wasnt sure what you were trying to do, assumed that it was for putting the posted values back in the form fields when you redisplay it on an error or something.
        try a print_r($_POST); on the receiving page and see if you get any of the values

          Write a Reply...