> I only want this INSERT INTO php sql script to run when the input button is
> pressed. How do I stop the script running when the page is loaded?

You have to make the query dependend on the action of the user.
So you put a condition into it:

if ($Submit) {
   //do your thing
}

Your form calls itself. If called first, $Submit is not defined.
When the user presses submit, the page is called again, but this
time the array $GLOBALS[HTTP_POST_VARS] is filled.

$GLOBALS[HTTP_POST_VARS][Submit] has value Save, and php creates
a variable $Submit with that value automatically, so you can use
this to test.

But generally, it is not that good an idea, as you can send your
form without using the submit button on IE (and on Netscape, if
there is only one field, as is typical on search boxes).

So rather than use

   if ($Submit)

you play safe with

    if (isset($Submit))


You can look at it with something like the following code (which
is what I use for testing puposes - I put it into a separate file
and just include this file if I want to see what's going on. It
shows arrays, too):

if (is_array($GLOBALS[HTTP_POST_VARS])){
        reset($GLOBALS[HTTP_POST_VARS]);
        while(list($key, $val) = each($GLOBALS[HTTP_POST_VARS])) {
                if (is_array($val)) {
                        echo '$' . $key ." is Array<BLOCKQUOTE><font color=#000080>";
                        while(list($ky, $vl) = each($val)) {
                                echo $ky .": ". $vl . "<br>\n";
                        }
                        echo "</FONT></BLOCKQUOTE>";
                }
                else {
                        echo '$' . $key ." = ". $val . "<br>";
                }
        }
        reset($GLOBALS[HTTP_POST_VARS]);
        echo "HTTP_POST_VARS -----sessionID-$sessionID----------*Test<br>\n";
}
else{
        echo "no HTTP_POST_VARS -----sessionID-$sessionID----------*Test<br>\n";
}
echo "<hr size=0><br>\n";


-- 
Herzlich
Werner Stuerenburg            

_________________________________________________
ISIS Verlag, Teut 3, D-32683 Barntrup-Alverdissen
Tel 0(049) 5224-997 407 · Fax 0(049) 5224-997 409
http://pferdezeitung.de



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to