Html form submission | Sololearn: Learn to code for FREE!

+11

Html form submission

after submitting a form and the user is on another page, if the user goes back to previous page how can I prevent the user from going back to the form

6/20/2020 1:38:47 PM

Daya Bianca

20 Answers

New Answer

+10

I understand your question Daya Bianca, you can do that by making the former page url expire, which is used by mist banks website, you can also use javascript to delete former page history. you can replece history, instead of using window.location = url; to redirect, try: window.location.replace(url); after using replace() the current page will not be saved in session history, meaning the user won't be able to use the Back button to navigate to it, bcoz after loading the page the history is replace with another url. replaceState may also help. This links may help also: https://stackoverflow.com/questions/37511043/how-to-stop-re-submitting-a-form-after-clicking-back-button https://www.the-art-of-web.com/javascript/doublesubmit/ https://www.w3schools.com/js/js_cookies.asp

+5

The submit of your form i.e. as follows: function withoutBack() { location.replace('http://www.myNewUri'); }

+5

Web is not something I am very knowledgable about. If you only use one page with divisions getting updated, back will take them off your site so no issue.

+5

A simple php session will do. You don't need to learn much. Start a session at the top of your page before any html using session_start(); and store data with $_SESSION Any other page that has session started will be able to access that data https://www.w3schools.com/php/php_sessions.asp

+4

The location.replace(URL_2); method replace browser history‘s last page URL_1 = „where is/was your form with questions“ with the web page URL_2. An example: <input id="myIn"> <button type="button" onclick="validateIn(this)">submit</button> <script> function validateIn() { var x = document.getElementById("myIn").value; if (x == "") { alert("This must be filled out"); return false; } location.replace('https://www.sololearn.com/'); } </script>

+4

Ja Play, the code can't be placed here, I am dealing with more than 1 web page, which sololearn code playgroubd does not support

+3

I had a question like that

+2

Instead the user should go to another page

+2

Which I will redirect the user myself

+2

Seniru how can I use cookies

+2

Ja Play pls how does the location.replace works

+2

John Wells, Oma Falk, Lord Krishna please I will like an explanation to this

+2

I hope you are okay with my answer Daya Bianca

+2

looking for team members to start a project with..

+2

kel Mar am interested

+2

kel Mar I'm interested

+1

Not sure, but maybe cookies is the answer

+1

Thanks Awojobi Godfrey, understood now

0

To use cookies is under the php programming language

-1