I'm assuming $submit is referring to the submit button.
First of all, the submit button isn't assigned to the variable $submit,
unless its NAME property is "submit". You could make a text field called
submit, a select box called submit, radio button, checkbox, etc. All it
depends on is which field is given the name="submit" in their tag. So,
unless you have specifically put name="submit" in your submit button, like
this:
<input type="submit" name="submit" value="Sign!">
then $submit is not going to register as a variable. Some basic debugging
could have told you this, like echoing the value of $submit. Why not try this:
echo "The value of submit is: $submit<br>\n";
if ($submit == 'Sign!') {
echo "Whatever";
}
That would be the logical first step in debugging. You ask, "Why is the if
statement not going through?" The first answer is, "Because $submit
doesn't equal 'Sign!'". Then you ask, "Then what does it equal?" And then
you echo its value.
But, even if you did all this, and made sure that the submit button was
named "submit" and its value was "Sign!", there is one thing you should
know: There is behaviour in some versions of Internet Explorer where the
value of the Submit button is not sent with the form if the button itself
is not clicked. But, you ask, when would a form be submitted without its
button being clicked? Well, you may have noticed that in IE you can submit
forms by hitting enter while focused within the form (though not within a
textarea, of course). So, if the user hits enter to submit the form, and
their browser allows it (i/e they're using MSIE), then the form will get
submitted, and if the browser doesn't send the value of the submit button
along since they didn't click it (i/e they're using a version of MSIE that
behaves this way), then your if statement on the next page won't go through
anyway, even though they submitted the form.
A better way to deal with this is to include a hidden field in ALL forms
you make, like this:
<input type="hidden" name="submitted" value="1">
That way, you can do something like this instead:
if ($submitted) {
echo "Whatever";
}
And it will work for all browsers.
-Mike
At 04:32 PM 4/10/02 -0300, Nik Alleyne wrote:
>I'm now trying to insert data into the database, but i seem to have a
>problem with my
> If ( $submit == "Sign!" )
> {
> echo "Whatever";
> }
>this is being done in a page called createentry.php which checks the submit
>button on a page called index.html
>
>once i place this statement in here the if nothin happens, but if i put it
>outside, everything works fine.
>
>Thx
>Nik
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php