Forms on PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux