jamesadrian — 2010-05-16T19:18:16-04:00 — #1
I have a .php file that contains an html form that begins with this:
<form method="POST" action="<?php echo $PHP_SELF;?>">
and has a submit button invoked this way:
<input type="submit" name="Submit" value="Submit Form">
I have discovered that the file does not work without including
even though I cannot find another instance of the word Submit in any other statement in the .php file. If I haven't missed a reference to it, is there some reason why name="Submit" is required?
Also, name="submit" doesn't work either. The string name="Submit" must be in the submit statement and it must be capitalized. I have seen on the Internet .php files that use only
<input type="submit" value="Submit Form">
for the submit button.
I would appreciate any clarification.
Thank you for your help.
tbakerisageek — 2010-05-16T19:52:46-04:00 — #2
This sounds like the method I use to submit data back to the server.
How I prefer to do this (for simplicity sake), is to have any forms submit the data back to themselves. Before any page out put is sent to the browser, I have a check looking for $POST['Submit'] (or $GET['Submit']) being set to the "Value" of the form element. The Value is the text that's displayed on the button, and in your case "Submit Form".
If the Variable is set to "Submit Form" that would mean that the form was filled out and the button was clicked. In this case, you'd want to then include the php file that evaluates, parses, checks, stores, processes, emails, or anything else you intended to do with the data.
I can gather up some sample code if my rambling explanation on how I use this is not clear. Let me know.
raffles — 2010-05-16T19:28:07-04:00 — #3
What do you mean by it "does not work"? As in, the form doesn't get submitted, or what?
Or of course, the other option is that you missed a reference to it. There could be some kind anti-spam check to ensure the submit button was used by a human user, rather than some robot submitting the form. If there are some included files in your PHP file, did you check in there?
jamesadrian — 2010-05-17T13:11:42-04:00 — #4
I can't believe it!
The very first statement after <?php is
That's where the reference is.
In a way, it is a fortunate mistake because your answers have introduced me to additional concepts in php and a more specific understanding of how these statements work.
Thank you all so much for your answers.
felgall — 2010-05-17T02:33:15-04:00 — #5
Somewhere near the top of the page there will be a test to see if $_POST['Submit'] exists in order to work out whether the form has been submitted and if so to process it. If the form hasn't been submitted or if there are errors then it eventually gets to the part of the code where it displays the form.
jamesadrian — 2010-05-17T01:28:59-04:00 — #6
Sample cod is always of interest. I'm not ready for a reply other that this because I am still confused.