0
<h1>Lalan</h1>
<input type="text" name="text" id="text" maxlength="12"> <label for="text"> Type your name here</label> <br><input type="submit" value="Submit"> </form>

I am having problem that how I can save it in the url like in many url the name is saved and to whom he only they can see it

Jaromanda X
  • 47,382
  • 4
  • 58
  • 76

1 Answers1

0

you need to persist the data somehow. And there are plenty of approaches to this. You could either use a cache like Redis or implement a record in your database. I think the easiest way would be through persisting the data in the query string that you´re going to share. There is a really good answer on how to achieve this here: [add or update your query string from code][1] [1]: https://stackoverflow.com/questions/5999118/how-can-i-add-or-update-a-query-string-parameter

once you have set the data in the query, you can look up if there is any information in your query, and if there is you can render it as the default value of your input. For that you can use:

const urlParams = new URLSearchParams(window.location.search);

const pastUserInput = urlParams.get(`pastUserInput`)