I registered, then I come in with this data, I didn’t come to problems, and then when I turn to view an order, I’ll automatically exit. Yes, my Russian makes itself felt.

Here are the pictures

1 Picture Registered but not logged in. enter image description here 2 Picture entered the system by their username and password. enter image description here 3 Picture I turn into orders, here and focus, as it is to leave the system enter image description here 4 Picture showing that I can not make an order. I am no longer in the system. enter image description here

Link to the files here enter the description of the link here

Closed due to the fact that off-topic participants are user194374, user207618, Alexey Shimansky , Alex , Denis 26 Dec '16 at 6:38 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Spirit of the community, Spirit of the community, Alexey Shimansky, Alex, Denis
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Need to save cookies / session - Volodymyr

5 answers 5

Well, firstly, your session does not start as you start it after the headers have already been sent, write it at the very beginning of the file!

  • And the code is available to you through the link - Rasulov Gamzat
  • I did it the way it says window.edu.ru/resource/937/79937/files/ECnew.pdf - Rasulov Gamzat
  • Well, I will not download your files now, I just explained to you what needs to be done, start the session at the very beginning of the file - quaresma89
  • On any go - Rasulov Gamzat
  • one
    Yes, each file at the beginning must have session_start (); - Rasulov Hamzat

IN THE BEGINNING, EACH SCRIPT MUST BE A STRING.

session_start(); 

And you have a session on the condition starts. I understand from your screenshot.

And maybe cookies are disabled in the browser?

    1. session_start (); // start the session
    2. if the login and password fields are filled in, then save them in the $ _SESSION ['login'] session = $ _POST ['login']; ... etc. for the password.
    3. then check the database, there is such a login, if there is, then check the entered password with the password that lies on the database.
    4. if all conditions return true, then create a session of the type $ _SESSION ['auth'] = 1;
    5. and at the beginning of each page, start the session and check if $ _SESSION ['auth'] exists and is equal to 1.
    6. if item 5 returns true, then show what the banned user should see and not show information for the guest. this is an easy way to work with the session; if it is interesting with cookies, we will be happy to help ask questions.

      If you do not want to use frameworks, we mean one of the most popular, that is, a solution for native PHP programming. The PHPAuth library is endowed with all sorts of possibilities from authorization to password recovery via email and localization of messages.

      In frameworks there are already built-in authorization components.

      And in your case - the session does not start where it is necessary and the headings are described after giving the content, which is impossible.

          <? $title="Авторизация"; $color="#aaaaff"; $pass=$_POST["pass"]; $login=$_POST["login"]; include("connect.phtml"); $strSQL1="SELECT * FROM customers WHERE login='".$login."' AND pass='".$pass."'"; $result1=mysql_query($strSQL1) or die("Не могу выполнить запрос!"); // пользователь с таким логином и паролем найдем ? if($row=mysql_fetch_array($result1)) { $start=session_start(); // начинаем сессию // Создадим сеансовую переменную для ФИО покупателя session_register("log"); $_SESSION["log"]=$row["fam"]." ".$row["im"]; // Создадим сеансовую переменную для ID покупателя session_register("id"); $_SESSION["id"]=$row["id_cust"]; $message="<tr><td bgcolor='#66cc66' align='center'> <b>Вы успешно авторизованы</b></td></tr>"; $success=true; } else { $message="<tr><td bgcolor='#ff9999' align='center'> <b>Таких логина/ пароля не существует!!!</b></td></tr>"; } mysql_close(); if($success) { include ("cabinet.phtml"); } else { include("header.phtml"); print $message; include("footer.phtml"); } ?> 

        Right here when launching she swears

         Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at D:\home\site.ru\www\auto.phtml:1) in D:\home\site.ru\www\auto.phtml on line 1 Deprecated: Function session_register() is deprecated in D:\home\site.ru\www\auto.phtml on line 18 Deprecated: Function session_register() is deprecated in D:\home\site.ru\www\auto.phtml on line 21