Jump to content


This topic is now archived and is closed to further replies.


How to redisplay form after submit

Recommended Posts

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 value

Here is my code (the bottom bit is where it is needed)
$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">


<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>



<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>


<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>



<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" >
    <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>
if (!isset($_POST['fund'])) {

<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
    <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">

else {
    $fh = fopen($myFile, 'w') or die("can't open file");
    $stringData = $name;
    fwrite($fh, $stringData);
    echo $thankyou_message;

Share this post

Link to post
Share on other sites
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 :)

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.