0

I want to set up a login page in which from anywhere on the site I can send a user to it and it will display a custom message along with it. I could use a redirect and a msg query param but is this the best way to do it?

I'm working with node.js but I'm interested in a universal solution.

ThomasReggi
  • 42,912
  • 63
  • 199
  • 343

2 Answers2

1

If you are going for easy, you can just have GET data in the URL. But, that doesn't look that nice, if you want a rather long message, plus, GET has size restrictions, where POST (virtually) hasn't.
For using post data you could use the solution of this: JavaScript post request like a form submit question, but that gives a rather messy source code (if you want a somewhat longer text).
You could keep them in a database, and only send the ID of the message to a PHP page, and get it from the database (that's what I would do, but that doesn't mean it's a good idea, just amateur here!)

Community
  • 1
  • 1
11684
  • 7,120
  • 10
  • 45
  • 69
1

You can use jQuery or simply plain javascript to extract your message from the url; the relevant question that listed links to detailed code: jquery get querystring from URL.

Then depending on how you want it displayed, apply the extracted string to your situation.

Community
  • 1
  • 1
Alexander Chen
  • 1,045
  • 1
  • 8
  • 16