AdRock Posted October 18, 2006 Share Posted October 18, 2006 This is probably a really simple question but i've had too many beers and I can't think straight.I have a form where i can update a text file but what I would like to do is to re-display the form with the updated info so if the user wants to update the text file they can.At the moment I have it so when the user submits a value in the form a message is displayed. I would like the form displayed with the new valueHere is my code (the bottom bit is where it is needed)[code]<?$myFile = "../includes/thermometer/testFile.txt";$name = $_POST['fund']; // vars from form$fund = file_get_contents($myFile);$empty_fields_message = "<p>Please go back and complete all the fields in the form.</p>Click <a class=\"two\" href=\"javascript:history.go(-1)\">here</a> to go back";$thankyou_message = "<p>Thankyou. Current fund amount has been updated.</p>";?><h2>Welcome to the Jack Godfrey Honeylands Support Fund Admin Area.</h2><p>What would you like to do?</p><form name="form"> <fieldset> <legend>News / Events</legend> <input style="border:none;" type="radio" name="loc" onClick="go('index.php?page=addnews');"> Add a news article<br> <input style="border:none;" type="radio" name="loc" onClick="go('index.php?page=edit_news');"> Edit a news article<br> <input style="border:none;" type="radio" name="loc" onClick="go('index.php?page=delete_news');"> Delete a news article<br> </fieldset><br> <fieldset> <legend>Coming Events</legend> <input style="border:none;" type="radio" name="loc" onClick="go('index.php?page=addevent');"> Add an event<br> <input style="border:none;" type="radio" name="loc" onClick="go('index.php?page=edit_event');"> Edit an event<br> <input style="border:none;" type="radio" name="loc" onClick="go('index.php?page=delete_event');"> Delete an event<br> </fieldset><br> <fieldset> <legend>Sponsors / Supporters</legend> <input style="border:none;" type="radio" name="loc" onClick="go('index.php?page=addsponsor');"> Add a sponsor<br> <input style="border:none;" type="radio" name="loc" onClick="go('index.php?page=edit_sponsor');"> Edit a sponsor<br> <input style="border:none;" type="radio" name="loc" onClick="go('index.php?page=delete_sponsor');"> Delete a sponsor<br> </fieldset></form><p style="border: 1px solid #c3c3c3; padding: 2px; text-align:center;"><em>Please note that once an article has been deleted, it is NOT recoverable</em></p><form action="index.php?page=uploader" method="post" enctype="multipart/form-data" > <fieldset> <legend>Upload a file</legend> <p style="margin-left:10px;">File to Upload:<br> <input type="file" name="file" size="30" ></p> <P><input type="submit" name="submit" value="Upload File" class="submit-button" style="margin-left:10px;"></p> </fieldset><br></form><?if (!isset($_POST['fund'])) {?> <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> <fieldset> <legend>Current Fund Amount</legend> <p style="margin-left:10px;">The current fund is:<br> <input type="text" title="Please enter the new current fund amount" name="fund" size="30" value="<? echo $fund ?>"> <input type="submit" value="Submit" class="submit-button"> </fieldset></form><?}else { $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = $name; fwrite($fh, $stringData); fclose($fh); echo $thankyou_message;}?>[/code] Quote Link to comment Share on other sites More sharing options...
btherl Posted October 18, 2006 Share Posted October 18, 2006 At the top you say[code]$name = $_POST['fund'];[/code]But in the form you put[code]<? echo $fund; ?>[/code]Maybe that should be echo $name ?But that doesn't make so much sense, since you only display the form if $_POST['fund'] is not set. I am very confused now :) 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.