php form elements

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
toonbone
Forum Newbie
Posts: 4
Joined: Thu Jan 20, 2011 10:21 am

php form elements

Post 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
brothaofdes
Forum Newbie
Posts: 21
Joined: Thu Jan 20, 2011 10:05 am

Re: php form elements

Post 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
toonbone
Forum Newbie
Posts: 4
Joined: Thu Jan 20, 2011 10:21 am

Re: php form elements

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: php form elements

Post 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.
brothaofdes
Forum Newbie
Posts: 21
Joined: Thu Jan 20, 2011 10:05 am

Re: php form elements

Post by brothaofdes »

John, you are correct, you should leave it blank as you showed it. Sorry, my mistake.
Post Reply