Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you allow users to dynamically create a web page within a web app? [closed]

For example, when a user adds a question to a Q&A site, that question typically gets its own web page, and that web page was created on-the-fly. How can you do this with PHP? Could anyone point me to any resources? Thanks.

like image 721
Justin Meltzer Avatar asked Dec 28 '22 07:12

Justin Meltzer


1 Answers

By "that question typically gets its own web page" you are referring to "gets its own url". For example, this one is How do you allow users to dynamically create a web page within a web app?.

It's really just a trick. Very simplified:

  • When you submitted this question, it got a unique identifier 3723813 and was inserted into a database.
  • There is a single controller script that deals with questions, say https://stackoverflow.com/questions.php
  • When someone tries to open this page, the server knows to send it to questions.php by using a module such as mod_rewrite for apache.
  • Then, questions.php looks at the url parameters, takes the unique id for this question, 3723813, and loads up its information from the database in order to display it.
  • The rest of the url is just cosmetic and just there so that we can right away know what question it is before opening the page.
like image 148
Fanis Hatzidakis Avatar answered Feb 26 '23 02:02

Fanis Hatzidakis