Solved

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

Posted on 2004-04-20
10
156 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:zoxman
Comment Utility
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
Comment Utility
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 18

Expert Comment

by:Plucka
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now