"Create or update" form behavior when hitting back button - html

I have the following workflow on a website:
Some user John Doe declares a company through form 1
(fields: name, head office location)
After John Doe submits (HTTP POST) form 1, he is redirected (HTTP 302) to company form 2 with additional legal information about the company.
The problem is, if John Doe hits the back button of his browser during step 2, he will land on the form 1, with data filled by the browser (using values he already submitted — that's what Firefox and major browsers seem to do).
John Doe might then think he can use this form to update some information (e.g. fix a typo in the name of the company) whereas he will actually create a new company doing so, as we don't know on the server side whether he wants to declare a new company or update the one he just created.
Do you know any simple solution to handle that problem ?

Use javascript/jquery script after the page is loaded to empty all the inputs. This will prevent confusion of "updating the company".
jQuery would look something like this:
$('#elementID').val('');

You can also handle the situation by manipulating the browser history
on load of form 2, and pass the CompanyId generated on submit of form 1 using querystring. So that you can actually update the company as the user
Suppose John submits form1.html, a unique CompanyId "1001" is generated and redirected to form2.html. Now on load of form2 you can modify the browser history form1.html?companyid=1001 using
var stateObj = { foo: "bar" };
history.pushState(stateObj, "page 1", "form1.html?companyid=1001");
Now, when the user click back button and submits the form1 again. you can check for companyid in querystring and update the company.

I think it is more user-friendly when user can return back to previous form and update it (instead preventing the described behavior).
I use in most cases similar way to handle described problem:
Let's assume that user is on the page /some-page, that contains "Create new company" button.
When the user opens this page, will be executed special method createOrFindCompanyDraft() on the server-side. This method creates new company "draft" record in DB (only for the current user). For example, draft record has primary key id=473. When you execute this method again it will return the same record with the id=473 (with "draft" status). "Draft" record should't display on any other interfaces.
And "Create new company" has link /company/common/473.
When user go to /company/common/473, you display form 1, that will be filled from "draft" record. At first time user will see empty form.
Technically user will update the existing record, but you can display "Create new company" title on the page.
Then user go to form 2, for example, /company/legal-info/473, you create similar draft record for the this form (similar to step 1).
When user submit the form 2, you will remove "draft" status from the record id=473 (and any related records).
Next time when user open page /some-page, will be created new draft record for the current user.
Browser history will contain:
/some-page
/company/common/473
/company/legal-info/473
/some-page2
I like this approach, because all form only update records. You can go to previous/next form many times (for example "Back"/"Forward" browser buttons). You can close browser, and open not completed forms tomorrow. This way doesn't require any additional manipulation with the browser history.

try this
<form autocomplete="off" ...></form>
And Another
Use temporary tables or session to store the Page 1 form data. If the page 2 form is submitted use the temporary data of page 1 which is stored in database or in session.
Use a Separate key (Hidden field ) in both page 1 and page 2.

Actually I thought of a trick to obtain that "create on first post, update after" behavior (just like the user thinks it should behave).
Let's say the step 1 form is at the URL /create_company/. Then I could have that page generate a random code XXX and redirect to /create_company/?token=XXX. When I create the company I save the information that it was created through page with token XXX (for instance, I save it in user's session as we don't need to keep that information forever) and when the form is submitted, if I know that a company was already generated using this token, I know the user used the same form instance and must have used the back button since the token would be different if he explicitly asked for another company.
What do you think ? (I initially thought there should be a simpler solution, as this seems a little bit over-engineered for such a simple issue)

This is more like a UX question.
I'd think that the solution lies within the information given to the user on that form, to help them understand what they're doing.
Set a title that says 'Create a company', for example, and set your submit button as 'Create Company' will help your user with that. Use a unique id when you create the company object, and pass the id back to the same URL in order to perform an update. You should then update your title and button that tells user that they are updating instead of creating.
In that sense I'd say it's better to use a more generic URL like /company and /company?id=12345.
You could also consider using Restful API protocol to help your server identifies the CRUD operation. http://www.restapitutorial.com/lessons/httpmethods.html

Without the "routing" part of django it is hard to help. I can just answer my experience from the express.js-router functionality:
you can specify a post on /company, which is for new users.
you can specify another route for post on /company/:companyid for a changing form
and as a response from the create-post you can redirect to the different location.

Related

Access 2010 - Bound Textbox - Only updating newest record created

I am trying to update the textbox for the current request that I have opened. After making changes to the bound textbox (regardless of the record number current being edited) it modifies the tblVendorRequests.VendorDiscussionNotes for the newest request created within the table.
My form is a Single Form
My record source for my form is a table (tblVendorRequests)
My textbox (txtVenConLog) is using tblVendorRequests.VendorDiscussionNotes as its control source
For instance, say I am trying to add notes "Hello World" to request number 242. Request 242's notes remain the same, but the "Hello World is added to the newest record instead (overwriting the existing text that was in the request).
I have done a good amount of searching on the topic, and have not found a satisfactory answer on why this would be.
Any ideas would highly appreciated!
I redesigned my form to split the functions into 2 separate forms and that seems to have resolved the issue. I believe the issue was that when I 'opened' a record, it was not behaving like it would if the record-opening function resulted in calling a form to open with specific criteria.

Copy data from one field to another field in a same Table(MS ACCESS 2013)

I'm learning MS access. So, pls tell me step by step.
Imagine a form where it asks user to input TWO information. One is Present Address and another one is Permanent Address.
I want to know how can I copy PRESENT ADDRESS data to PERMANENT ADDRESS data. But I don't want it to copy immediately. If I click a certain Button and PERMANENT ADRESS is empty(null) then it copy the data.
I found a video on youtube but it showed how to copy one form to another… Want to do it in same form…
Pls reply… Thanks is advance…
Using the OnClick event of the button, that will be:
If IsNull(Me![Permanent Address].Value) Then
Me![Permanent Address].Value = Me![Present Address].Value
End If
I assume that the only reason for "present address" to be different from "permanent address" is if it is actually a "temporary address".
I would approach this differently. Instead of calling the non-permanent address the "present" address, call it the "temporary" address. Also, add a boolean (yes/no) field named UseTemporaryAddress. Then you can use a query to get the present address, instead of pulling the data directly out of the table:
PresentAddress: IIf([UseTemporaryAddress], [TemporaryAddressField], [PermanentAddressField])

Creating a URL that will randomize at intervals and remove access to past URLs

Okay, I know this question has been half answered around here, but I'll explain in full and see if there maybe a better way to handle this then in just two parts.
I'm building an HTML5 voting site, that will close voting every half hour. And then open a new batch of voting.
What I need to do, is have the URL of this site be 'masked' ie:
have a random URL for it be generated that leads to the same location- so say I'm directing users to voting.com, I want them to only access it via the url votingstuff.com/hg67, and have that end portion be changed every half hour- and once the new url is generated, remove access to the site via the old URL.
I might add that after the user votes, I'd also like to close their voting access until the new URL is posted. AKA- everyone only gets one chance to vote.
Thoughts? Libraries to check out? Sites that do this? I know the randomization has been answered a few times, but usually it's a generator led to by a page, I want to START with a randomly generated URL, and not have a page that creates it as a function. I may have to write code that generates the page I guess?
Here is an approach I can think of -
You don't need to handle multiple URL's, you can achieve this on the same URL itself by enabling/disabling access to the URL content every hour.
You will need some action on your application/server side as well. For reference lets assume you have a PHP server running. You will need some table that holds a status setting for you, something like this -
Settings Table
id settingCode value
=============================
1 votingOpen 1
You will also need to setup a cron job on your server that will run every half an hour. The cron job's task would be to run every half an hour & change the value of the votingOpen to its inverse. So assume open your votings, initial value of the votingOpen field would be 1 i.e the first half an hour of voting starts.
Along with this you will start the cron job as well. Now what will happen is that after half an hour the cron job will fetch the value of votingOpen read it & if its 1, it will change it to 0 & if its 0 it will change it to 1. This will happen every half an hour on your server.
Now you need to make this votingOpen variable accessible on your client side code using a simple query to fetch its value. On each render of your voting page, on top somewhere you can check this value & if its 1 i.e true, you will write the logic to go ahead & show the voting page. But if its 0, you can redirect the user or show a different message on that page.
Lets say your voting happens on http://somedomain.com/voting, on the render logic of this page you can do something like this -
Voting View Logic
<?php
$votingOpen = {some database query that fetches the value from the database};
if($votingOpen) {
// your voting view resides here
} else {
// either redirect user to some other page
// or show some message like voting is closed on this same page.
}
?>
Limit multiple votes from one person
Normally the best way to handle this is a combination or registered user only vote + cookie/localStorage + IP tracking
But if you don't have registered user voting, you can still capture IP of user & allow only one vote per IP and you can also set a cookie or a localStorage variable in the users computer so he can only vote once.
Hope this helps.
Ref for Cron Job - http://code.tutsplus.com/tutorials/managing-cron-jobs-with-php--net-19428

MediaWiki: Special "Create an account" behaviour

When a new user account is created in our MediaWiki system, the admin specifies the desired user login name and the real name. I'd like to automatically fill the user page and also create a special page according to these rules:
Provided the login of the new user is "LOGIN" and the real name is "FIRST SECOND",
1) a new page should be created named "SECFIR" (i.e. 3 letters of surname and 3 letters of first name), containing just "#REDIRECT:[[user:LOGIN]]", i.e. redirecting to the user page;
2) the user page should contain "{{getuser|SECFIR}}"
Any suggestions?
Create a custom hook function (event handler) using http://www.mediawiki.org/wiki/Manual:Hooks/AddNewAccount - relatively straightforward PHP to do this
Same answer...
More at https://stackoverflow.com/a/8514696

Designing Database

I need to design database with frontend as HTML.
This is my first attempt to do this.
What I need is,
- User can input a word from HTML page, click submit
I will query the word to get a URL from database and user sees that webpage(pointed by URL).
Just enter word, submit and get the webpage displayed.
People suggested using JSP/Access. I am new to everything.
Can you please point out what exactly I need to do?
Thanks a ton.
Following is the way you need to approach
Step1:
Create an HTML page which can take an input from the users
Step 2:
After getting the data from the user, create a connection to the database and pass the searched string as an input paramater.
Step 3:
You will get a result set from a database
Step 4:
Iterate through the result set and display in the html page, if you require the url to be given for those url, so when user clicks So that he will be directed to those websites.
Sample Query:
Select * from table1 where url_Word like '%Search_String'
This will be the procedure that you need to follow to complete your work.
You do not need a database you need a text file. If this is a school project you need more information.