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

余生长醉 提交于 2020-01-22 16:00:06

问题


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.


回答1:


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.



回答2:


"How to" on this is bigger than a normal Stackoverflow question.

Maybe have a look here for some ideas(I'm just quickly scanning through it right now, can't really say if it's a great tutorial or not right now): http://www.tuttoaster.com/how-to-create-a-forum-in-php-from-scratch/

If you're a php novice, it may be better to look for one of the open source PHP forum applications like http://www.phpbb.com/ or something like that (phpbb just being the first that came to mind). That will be a lot more code to sort through, but the more popular open source applications will likely already know how to deal with security concerns like cross site scripting attacks and sql injection attacks.



来源:https://stackoverflow.com/questions/3723813/how-do-you-allow-users-to-dynamically-create-a-web-page-within-a-web-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!