You are here: Forms on PHP « PHP « IT news, forums, messages
Forms on PHP

Posted by PHPDiscuss - PHP Newsgroups and mailing lists on 10/01/98 11:05

Hi,

I am new to this or any newsgroup in PHP, as well as PHP itself, so this
question is probably rather elementary. I have a form which on clicking
on the "Submit" button calls up a compiled program on the server that is
executed and writes output to a file. This file is then read by the PHP
script and passed on for other processes. When the page is first loaded,
it knows that the "Submit" button has not been clicked, and after clicking
the button it knows, which is of course what we want. The problem is that
subsequently it always thinks the button has been clicked, even if the
reload button on the browser has been clicked.

Here is a cut down version of the code, where for brevity I have removed
all inputs other than n:

<pre>
<form method="post" action="<?php print $_SERVER['PHP_SELF'] ?>">
Type in the following parameters:
<!-- Various other entries omitted such as a, i, e etc. -->

<input type="text" name="n" value="1000" size="6">

<input type="submit" name="form_sumbitted" value="Submit">
</form>
<p>
<?php
// Start of PHP code - Extract values from form.
/* Other values read */
$n=$_POST['n'];

// Pass the data from the form to lightcurve_csharp
$command="./lightcurve_csharp $a $i $e $lomega $bomega $lambda $n";
$result=`$command`;

$form_submitted=$_POST['form_sumbitted'];
if (isset($form_submitted)) {
if ($form_submitted) {
echo 'The form has been submitted<br>';
unset($form_submitted);
}
} else
echo 'The form has not been submitted<br>';

The input value of $n is picked up from $n=$_POST['n'] which has the
default of 1000, and I test that "Submit" has been clicked by looking at
the state of $form_sumbitted. Unfortunately this only works the first
time the page is loaded, and subsequently it is always flagged as set.

This is a test for only writing some text below the form if it has been
clicked. Subsequently, when the page is refreshed or is clicked again
with new data, the text below the form should disappear until the
calculations have been completed. The form is implimented at
http://proteus.as.arizona.edu/~csharp/sudarsky/lightcurvec.php .

I would be very grateful for some kind help on this.

Christopher Sharp
http://csharp.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация