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
zoxmanAsked:
Who is Participating?
 
PluckaCommented:
Hi zoxman,

Not sure if the above will work, don't think so.

What you could do, is action to index.cfm and in index.cfm first line could store the form variables and reloacte, the user will never see the index.cfm

so in index.cfm have

<cfif NOT IsDefined("Session.Form")>
      <cfset Session.Form = StructCopy(Form)>
      <cflocation url="http://localhost/project/home/">
</cfif>

<cfset Form = StructCopy(Session.Form)>
<cfset StructClear(Session.Form)

Then do the form processing as normal on form. variables.

So in summary, it makes a copy of the form variables in session.form and changes back to it'self with the newurl. This will happen so quickly you won't see the index.cfm. It also requires no IIS setup.

Regards
Plucka
0
 
anandkpCommented:
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
0
 
anandkpCommented:
oops guess the form tag isnt all readable

<form name="frm" action="/" method="post">
.
.
.
.
</form>
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
zoxmanAuthor Commented:
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
0
 
zoxmanAuthor Commented:
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
0
 
PluckaCommented:
anandkp,

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

Regards
Plucka
0
 
PluckaCommented:
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.
0
 
PluckaCommented:
zoxman,

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

Regards
Plucka
0
 
PluckaCommented:
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
0
 
mrichmonCommented:
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?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.