jcbarr Posted March 20, 2007 Share Posted March 20, 2007 Any ideas why this script isn't picking up the $editdraft variable that is being sent via the form at the bottom of the script? <html> <head> <title>Draft Admin</title> </head> <body><BR><BR><BR><BR><BR> <center> <a href=admin.php?CREATE=Y>CREATE DRAFT FILE</a> <P> <a href=admin.php?EDIT=Y>EDIT DRAFT FILE</a> <P> <?php //Gather Variables $create = $_GET['CREATE']; $edit = $_GET['EDIT']; $make = $_POST['make']; $year = $_POST['year']; $type = $_POST['type']; $draft = $_POST['draft']; $editdraft = $_POST['editdraft']; echo $editdraft; //Create Draft File Form if (!empty($create)){ echo <<<END <b><h2>CREATE DRAFT</h2></b> <form method="post" action="admin.php"> <input type="hidden" name="make" value="Y"> <input type="text" name="year" value="Type Year Here"> <select name="type"><option value="FA">Free Agent</option> <option value="AM">Amateur</option> </select> <input type="submit" value="Create Draft"> </form> END; } //Create TXT File For Draft if ($make=="Y"){ $filename = "$year$type"; $ext = ".txt"; fopen("drafts/$filename$ext", "w+"); echo "$filename has been created. Click <a href=admin.php>here</a> to refresh page."; } //Make Select Edit Form if ($edit=="Y"){ ?> <B><h2>SELECT DRAFT FILE TO EDIT</b></h2> <form name="form1" method="post" action="admin.php"><select name=draft onchange=form1.submit()><option value=''></option> <?php $dir = "drafts"; $dh = opendir($dir); while (false !== ($filename = readdir($dh))) { $files[] = $filename; } sort($files); foreach ($files as $drafts){ if ($drafts !== '.' && $drafts !== '..'){ $drafts = substr($drafts, 0, 6); echo "<option value='$drafts'>$drafts</option>"; } } ?> </select> </form> <?php } //Make Edit Form if (!empty($draft)){ $ext = ".txt"; $filename = "$draft$ext"; $text = file_get_contents("drafts/$filename"); echo <<<END <form name='form2' method='post' action='admin.php'> <input type="hidden" name="editdraft" value="$filename"> <TEXTAREA NAME="edit" ROWS=50 COLS=50>$text</TEXTAREA> <BR> <INPUT TYPE="reset"> <INPUT TYPE="submit" NAME="submit" VALUE="Submit"> </FORM> END; } //Write To Draft File if (!empty($editdraft)){ $handle = fopen("$editdraft", "w+"); fwrite($handle, $edit); fclose($handle); echo "$editdraft has been edited. Click <a href=admin.php>HERE</a> to refresh page."; } ?> </center> </body> </html> Quote Link to comment Share on other sites More sharing options...
monk.e.boy Posted March 20, 2007 Share Posted March 20, 2007 <?php } //Make Edit Form if (!empty($draft)){ $ext = ".txt"; $filename = "$draft$ext"; $text = file_get_contents("drafts/$filename"); echo "<form name="form2" method='post' action='admin.php'>"; echo "<input type="hidden" name="editdraft" value="$filename">"; echo "<TEXTAREA NAME="edit" ROWS=50 COLS=50>$text</TEXTAREA>"; echo "<BR>"; echo "<INPUT TYPE="reset">"; echo "<INPUT TYPE="submit" NAME="submit" VALUE="Submit">"; echo "</FORM>"; } //Write To Draft File if (!empty($editdraft)){ $handle = fopen("$editdraft", "w+"); fwrite($handle, $edit); fclose($handle); echo "$editdraft has been edited. Click <a href=admin.php>HERE</a> to refresh page."; } ?> You need to sort out the quotes. monk.e.boy Quote Link to comment Share on other sites More sharing options...
per1os Posted March 20, 2007 Share Posted March 20, 2007 I would check the filename, chances are that is where the error is., I never used the <<<END and END; Try it this way: echo '<form name="form2" method="post" action="admin.php"> <input type="hidden" name="editdraft" value="'.$filename.'"> <TEXTAREA NAME="edit" ROWS=50 COLS=50>$text</TEXTAREA> <BR> <INPUT TYPE="reset"> <INPUT TYPE="submit" NAME="submit" VALUE="Submit"> </FORM>'; see what happens. Quote Link to comment Share on other sites More sharing options...
jcbarr Posted March 20, 2007 Author Share Posted March 20, 2007 That isn't where the problem lies, the file is opening fine and populating the text area, so I know that the filename is right, when I view source it even shows up in the input tag, but it won't pass it to the script when the form is submitted. Quote Link to comment Share on other sites More sharing options...
jcbarr Posted March 20, 2007 Author Share Posted March 20, 2007 Figured it out, can't submit a form variable with the .txt or whatever, took off the .txt and it works now. Now just to test to make sure it is writing to the file. Thanks for the help guys. Quote Link to comment Share on other sites More sharing options...
jcbarr Posted March 20, 2007 Author Share Posted March 20, 2007 Okay, nevermind. It's back to not working. It worked the first time after I uploaded and now it won't work again...who knows what the hell is going on... Quote Link to comment Share on other sites More sharing options...
jcbarr Posted March 20, 2007 Author Share Posted March 20, 2007 Here is the deal if anyone cares. Apparently it had to do with my browser settings at home. My browser was apparently not loading the page again it was just using a cached version or something like that. I get to work and the thing works without a hitch, so I guess everything is okay now. Quote Link to comment Share on other sites More sharing options...
monk.e.boy Posted March 21, 2007 Share Posted March 21, 2007 <SHIFT>+F5 works like a charm to flush the cache of that page and force a re-load. Get used to tapping that key combo ;D monk.e.boy 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.