Hello. I have the following question, how can the users of the site be tied up, for posting messages to them, for example, in the guest book. After the user logged into the site, and he wanted on his own behalf to leave a message in the guest book. How to do this on the site, I have no concepts, maybe I have. But I don’t understand how to bind users to the form.
- correct the question tags, bind the question to at least one programming language, or CMS. - Vladyslav Matviienko
- corrected on php and mysql - serk
|
2 answers
If the question is how to remember an authorized user, then during authorization, after checking the login / password, use something like:
$_SESSION['mysite_uid'] = $id); //Устанавливаем переменную сессии mysite_uid в значение идентификатора пользователя, из БД.
Each time the page loads, check if there is a session and a variable with the following name:
session_start(); // Проверяем наличие сессии. Если нет, она создаётся if(isset($_SESSION['mysite_uid'])) { //Пользователь авторизован //Забираем из базы нужную информацию, для пользователя с id равным $_SESSION['mysite_uid']. } else { //Нет авторизации, предлагаем войти или зарегистрироваться. }
When a user leaves the site:
unset($_SESSION["mysite_uid"]); //Удаляем id. session_destroy(); //Убиваем сессию.
- put uid in cookies ?? - zb '
- @eicto, no, well, write a session there, but what for? For a guest book? I do not understand, what the hell is authorization? - Risto
- Well, this is the case of the vehicle, why authorization, but the uid in the cookie ... do you often write authorization in this way? - zb '
- @eicto, no, I use sessions, or hashes. But it seemed to me that in this case this was enough. However, already rewrote. - Risto
- I need a hint in the following: there is a form proet.ru/2214.jpg . Where is the user's logan "(in red) and which information I need to prompt" which code to enter, which eventually resulted in: user XXX (from the database) wrote an FFF message. - serk
|
Learn English and in any tutorial (tutorial). Your question is too general, there are a lot of solutions. Learn to ask questions first on Google.
- I need a hint to the following information: When a user logs into the site, and he wants to leave a message in the guest. How to enter the data in the forum. - serk
- To the pots when the form is updated in the database and goes to the site. The user can see on the site your name and your message. - serk
- 3Considering your comments, you are not well versed in the matter. That is why, I advise you to learn. And you expect people to make a ready decision. If you need a ready-made solution, look for it on the Internet - lvil
- I need a hint in the following: there is a form proet.ru/2214.jpg . Where is the user's logan "(in red) and which information I need to prompt" which code to enter, which eventually resulted in: user XXX (from the database) wrote an FFF message. - serk
- It is clear that without a cookie. Since the user is already on the site, but the name while he writes himself when filling in the fields. And I wanted that the program itself recorded it when sending data to the site. When data should be inserted into the database table and displayed on the site. - serk
|