Solved

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

Posted on 2004-04-20
10
158 Views
Last Modified: 2013-12-24
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
0
Comment
Question by:zoxman
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 17

Expert Comment

by:anandkp
ID: 10867249
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
 
LVL 17

Expert Comment

by:anandkp
ID: 10867260
oops guess the form tag isnt all readable

<form name="frm" action="/" method="post">
.
.
.
.
</form>
0
 
LVL 18

Accepted Solution

by:
Plucka earned 25 total points
ID: 10867517
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:zoxman
ID: 10867565
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
 

Author Comment

by:zoxman
ID: 10867591
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
 
LVL 18

Expert Comment

by:Plucka
ID: 10867594
anandkp,

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

Regards
Plucka
0
 
LVL 18

Expert Comment

by:Plucka
ID: 10867616
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
 
LVL 18

Expert Comment

by:Plucka
ID: 10867619
zoxman,

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

Regards
Plucka
0
 
LVL 18

Expert Comment

by:Plucka
ID: 10867678
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
 
LVL 35

Expert Comment

by:mrichmon
ID: 10870005
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

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question