Link to home
Start Free TrialLog in
Avatar of zoxman
zoxman

asked on

Form Post/Submit to directory/path (default file in directory)

Could someone please tell me if there is a way to submit a form to the default file in a directory without actually specifying the file name in the URL. Here is the scenario:

I have the path: http://localhost/project/home/

I would like my form to submit to the index.cfm file within the aforementioned path. However, I do not want to specify http://localhost/project/home/index.cfm in the action attribute of the form, I just want to use the path, without the file name to tell it where to submit to - http://localhost/project/home/

The goal here is that I do not want the URL http://localhost/project/home/index.cfm to show up in the browser's location bar, but would prefer that it just reads http://localhost/project/home/ in the location bar.

I hope this makes sense. Please let me know if you might have a solution to this.

Thanks,

Zach
Avatar of anandkp
anandkp
Flag of India image

Hi,

normally this wldnt be possible  -althou u ahve a workaround for this

if this http://localhost/project/home/ is ur ROOT directory for the project [on the live server i mean - localhost wld have localhost as the root dir]

then u cld have ur action go as  : <form action="/ ....

& u cld have index.cfm mapped as a default document inside the folder "/home" & then it shld work the way u want it to be ...

let me know ...

K'Rgds
Anand
oops guess the form tag isnt all readable

<form name="frm" action="/" method="post">
.
.
.
.
</form>
ASKER CERTIFIED SOLUTION
Avatar of Plucka
Plucka
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zoxman
zoxman

ASKER

Anand,

Thanks for the quick response. I had already tried what you are saying without any luck.

The root directory for the project is actually http://localhost/project/ here, where as http://localhost/project/home/ points to the home directory within the root.

I am able to view the index.cfm page, in the home directory, in my browser by typing in the url http://localhost/project/home/, which would lead me to believe that the default document set-up for the folder, index.cfm, is working. However, if i use any of the following in the action of the form these don't seem to work:

action="http://localhost/project/home/"
action="/project/home/"
action=""

Where as the following does work, but is obviously not what I am looking for:

http://localhost/buffHookUp/picture/index.cfm
action="/project/home/index.cfm"
action="index.cfm"

Not that I would think it would make any difference but this is all being developed on my machine locally, rather than being tested on a live server.

Thanks,

Zach
Avatar of zoxman

ASKER

Plucka,

Though I have not tried your solution, it sounds like it would probably work. However, I was hoping that I would not have to redirect the user. Is there any way of accomplishing what I want without redirecting the user? I should have mentioned this earlier. Or am I just going to have to live with it and move on...

Thanks,

Zach
anandkp,

Didn't think that would work. My solution works have used it before. Let me know.

Regards
Plucka
If it's just a matter of hiding URL's you can put your page with a frameset one hidden and the other one the entire page, this way the url shown to the user never changes.
zoxman,

Perhaps if you tell us why you don't want to show it we can suggest another way.

Regards
Plucka
zoxman,

Another option is to have a hidden IFRAME on the page, make the form post there then have some code in the action page to send the main page back to where you want it to end up. I wouldn't clasify this as redirecting after all submiting a form is taking you to another page.

Regards
Plucka
I don't think that it will work because what happens when you type in http://localhost/project/home/ is that your browser does a redirection to the default home page if there wasn't one in the string.  It is similar to the redirection that is done if you type http://localhost/project/home (without the trailing slash) - you are redirected to thepage with the / and then to the default page.  When this happens you lose your form data since a redirect was done.

So you can try http://localhost/project/home/ with the trailing slash, but if it doesn't work then you will have to use some form of redirection such as cflocation.

Why is it that you don't want the file to show NOR to redirect?