Page 1 of 1
php form elements
Posted: Thu Jan 20, 2011 10:31 am
by toonbone
Sorry for bothering you guys about this. I have no php experience (though I think I'm about to get some) and I noticed that the HTML <form> element generated by a particular .php program has no action item. The HTML generated is simply
<form name="formrequest" method="post" onsubmit="return check(this);" >
Is this normal. How does this work?
Thanks for your help,
toonbone
Re: php form elements
Posted: Thu Jan 20, 2011 10:46 am
by brothaofdes
The action portion of the <FORM> element directs the page where to go when a form element is selected (i.e. a button is pressed). If you leave it blank, the form will go back to the page that called it.
For more information, see:
http://www.w3schools.com/html/html_forms.asp
Re: php form elements
Posted: Thu Jan 20, 2011 2:58 pm
by toonbone
Well, actually I didn't see anything in the W3schools reference that said you could leave the action attribute out. But anyway, you say, "If you leave it blank, the form will go back to the page that called it." This is not clear to me. It was a browser that called the page, and the page called was something.php which generated the form element as part of the HTML submitted to the browser. So if we submit a form that doesn't have an action attribute, are we sending the form back to something.php on the server?
Thanks
Re: php form elements
Posted: Thu Jan 20, 2011 3:14 pm
by John Cartwright
Your not supposed to leave the action variable out, I'm not sure that would validate. Your supposed to leave it blank. I.e., action="".
What they were trying to say is whatever page your form is displaying on, lets call it form.php, then if you leave your action blank it will be defaulted to form.php.
Re: php form elements
Posted: Thu Jan 20, 2011 3:28 pm
by brothaofdes
John, you are correct, you should leave it blank as you showed it. Sorry, my mistake.