Jump to content

<Form action="...">


OZZIE
 Share

Recommended Posts

Hello. Im wondering about the action attribute.Im using a template with a form inside it.I use php require to extend my files.Now when this form is submited I want it to submit the file that has required the template file. This happens automaticly when I dont specify action for the form, since the browser opens the file and not the template first.Maybe this sounds confusing to you so I'll make an example:

template file:---------------<form>.....</form>index.php-----------<?phprequire('template');?>

One sollution to this problem is either have a unvalid page = not specifying action.or using php = action="<?php echo $_SERVER['PHP_SELF']; ?>".However I find it odd that this can't be done in xhtml/html...Why not just add a value to action? Like action="none" or similar?Best reguards OZZIE

Link to comment
Share on other sites

While the <form> element's attribute action is required, it must be added. I suggest you do so, or turn back to Xhtml 1.0 transitional :)PHPs superglobal server variable can be used, as for html can't do anything from serverside. And the location is at the server side so html can't read it :)

  • Like 1
Link to comment
Share on other sites

PHPs superglobal server variable can be used, as for html can't do anything from serverside. And the location is at the server side so html can't read it :)

It can be done both server and client side, since your client experiences it visits index.php and not the required file.What I mean is, the client/webbrowsers url is the one the form should use, because requiring a file in php makes the file just extend the information. So the client experices it as if it only had been one file all along. Therefor not specifying action will submit to the correct page as I tried to explain before.The only problem is you dont allow it in your xhtml 1.1 standard for What reason? :SThats why Im suggesting that you add a feature for this in new standards. I mean I cant see any down sides with it. If there are tell me plz....
Link to comment
Share on other sites

A form is an area inwhich the user can input data, at some site.The data should always go somewhere, so that is why ACTION is required.Using Xhtml 1.1, which is strict to those require rules, it is prohibited to leave the action attribute. If you are not about transmitting the data in the form to a server-side program, why do you use a form then?That it what it is for :)

Link to comment
Share on other sites

Dan, What he is saying, I think, is that if he leaves the action attribute empty the form submits tot he page it is on.So if you are on index.php and you submit the form with action="" it is the same as action="index.php"It works fine but just isn't valid XHTML 1.1.OZZIE,

The only problem is you dont allow it in your xhtml 1.1 standard for What reason? :SThats why Im suggesting that you add a feature for this in new standards. I mean I cant see any down sides with it. If there are tell me plz....
who are you talking to/about???? w3schools??? They do not set web standards. This is a tutorial site. the W3C (w3c.org) sets web standards not w3schools.Like Dan said, maybe you will have to downgrade to 1.0 transitional for this page or set a session variable on page load that contains the current url and then insert that into the action.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...