Should I self-submit forms or submit to an externa

2019-07-02 16:23发布

I'm fairly new to programming - specifically Coldfusion, and I'm curious if it makes a difference whether I submit a form to the page it's on and process the results there, or if it should be submitted to an external file for processing, and then redirected from there?

1条回答
爷的心禁止访问
2楼-- · 2019-07-02 16:38

It can make a difference. When I first started programming I would often do things like:

myform.cfm(get/post) -> myformresults.cfm(get/post)

At first it seemed like this was a reasonable approach. The form and the form results often look quite different. They interact with DBs quite differently. In the long term this has not turned out to a good approach. Now I typically:

myform.cfm(get) -> myform.cfm(post)

Reason 1: If the form when it was posted, had issues I am already in the right place to re populate it.

Reason 2: HTTP gets are intended to get data without manipulation. HTTP posts are intended to manipulate data. This keeps with the already established pattern

Reason 3: There is less to debug. because there are fewer combinations of pages and methods

Reason 4: It is often useful in programming to see what is common, and not what is different. You may very well find that the your myformresults.cfm page really is quite similar to myform.cfm

Reason 5: .Net developers are already doing this. If you work in a shop that uses .Net, they are already expecting this distinction to be present

查看更多
登录 后发表回答