Jump to content


How to redisplay form after submit

  • Please log in to reply
1 reply to this topic

#1 AdRock

  • Members
  • PipPipPip
  • Advanced Member
  • 911 posts

Posted 18 October 2006 - 12:26 AM

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;

If your topic has been solved, please mark the topic as SOLVED.

This helps others from identifying which topics need help still

#2 btherl

  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 18 October 2006 - 03:16 AM

At the top you say

$name = $_POST['fund'];

But in the form you put

<? echo $fund; ?>

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

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users