Jump to content

[SOLVED] Input Form Question


TFD3

Recommended Posts

I'm trying to set up an input form so when I enter information using the input form the info I type in is sent to another page and placed in a table. That I already have set up but when I hit the refresh button the data in the table is erased.

 

Here is the links for adding data to the table:

http://beta.alabamaweather.org/dispatch/dispatch.php

After you type in information in the blanks and click the Submit button you get sent to this page along with the data that you typed in:

http://beta.alabamaweather.org/dispatch/index.php

 

Here is the input form im using:

<html>
<body>
<title>Dispatch</title>

<b>  <?php date_default_timezone_set('UTC');
echo date(DATE_RFC822);?></b>
<form action="index.php" method="post">
<TABLE BORDER="0" CELLPADDING="2" CELLSPACING="2" WIDTH="50%">
<TR>
<TD>Received:</TD>
<TD><input type="text" name="received" size=60 maxlength=100/></TD>
</TR>
<TR>
<TD>Type of Call:</TD>
<TD><input type="text" name="calltype" size=60 maxlength=100/></TD>
</TR>
<TR>
<TD>Location:</TD>
<TD><input type="text" name="location" size=60 maxlength=100/></TD>
</TR>
<TR>
<TD>Unit(s):</TD>
<TD><input type="text" name="unit" size=60 maxlength=100/></TD>
</TR>
<TR>
<TD>Details:</TD>
<TD><input type="text" name="details" size=60 maxlength=150/></TD>
</TR>
</TABLE>
<input type=submit value="Submit Incident"><input type=reset value="Reset Form">
</form>

</body>
</html

 

On the output page which is http://beta.alabamaweather.org/dispatch/index.php

<?php echo $_POST["received"]; ?>
<?php echo $_POST["calltype"]; ?>
<?php echo $_POST["location"]; ?>
<?php echo $_POST["units"]; ?>
<?php echo $_POST["details"]; ?>

 

 

My question is...How do I keep the data that I type in placed in the table without having it erased when I hit the refresh button?

 

Link to comment
Share on other sites

You get a mysql database and save it in there ;). OR learn file IO and you can save it in there, much harder in my opion.

 

You can also learn to save it to a txt file if you do not wish to use mysql database's yet.

(Or if its not a permanent "viewable" text, just use cookies)

Link to comment
Share on other sites

You get a mysql database and save it in there ;). OR learn file IO and you can save it in there, much harder in my opion.

 

You can also learn to save it to a txt file if you do not wish to use mysql database's yet.

(Or if its not a permanent "viewable" text, just use cookies)

 

text files are highly unsafe and can be downloaded by anyone once its found... Go for mysql it's very simple.

Link to comment
Share on other sites

Thanks for the replies guys!

I would like to do this the easier way because I am still learning PHP. I dont know much about SQL right now.

I would like to try saving it to a txt file. Can you help me set it up?

Link to comment
Share on other sites

I have done some searching and have found this script that is the "idea" of what I need.

However when u run the script there is only one input field and I need to add another.

Can someone show me what to add to make another input field?

Here is the script on the server:

http://www.alabamaweather.org/beta/dispatch/call1.php

 

And here is the script its self:

<html>
<head><title>Form Elements to file</title></head>
<body bgcolor="#002233" text=white>
<H1>911 Dispatch Logs</h1>
<?php

// This is a form with "sticky" fields .....

?>
<form method=post>
Text Box <input name=one
  value="<?php
  echo (htmlspecialchars(stripslashes($HTTP_POST_VARS["one"])));
  ?>" size=15><br>
Checkbox <input name=two type=checkbox
  <?php
  if ($HTTP_POST_VARS["two"] != "") echo ("checked");
  ?>><br>
Select <select name=three>
  <?php
  $compass = array ("North","South","East","West") ;
  foreach ($compass as $possibility) {
     echo ("<option");
     if ($HTTP_POST_VARS["three"] == $possibility) echo (" selected");
     echo (">$possibility");
  }
  ?></select><br>
<input type=submit>
</form>
<?php

// Save all the fields on any previous form to a file

$fh = fopen("../testdata","a");
fputs($fh,$HTTP_POST_VARS["one"]." - ".
  $HTTP_POST_VARS["two"]." - ".
  $HTTP_POST_VARS["three"]." - ".time().
  "\n");
fclose($fh);

// Echo the file contents onto the end of the form

$stuff = implode("",file("../testdata"));
echo (nl2br(htmlspecialchars(stripslashes($stuff))));

?>

</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.