Well, for example:

$_SESSION['username'] = $username; 

This is what the user login displays. And how to bring more to the login and his real name? (It is indicated at registration)

Thanks in advance.

And so it was like this on his page:

Welcome "Name", you are logged in under the login "Login"

  • 2
    Not so necessary: ​​<br> <br> <i> Who </ i> to drive two variables? The pipes are burning! - Ali

1 answer 1

  $_SESSION['realname'] 

Do not confuse. The array key must be realname. Otherwise, nothing will work. trollface

Useage:

 $sql = 'select `realname`,`username`,`sex` from `users` where `username`='.$username.' and `password`='.md5($password); $res = mysql_query($sql); if(mysql_num_rows($res)==1){ $row = mysql_fetch_object($res); $_SESSION['username'] = $row->username; $_SESSION['realname'] = $row->realname; switch($row->sex){ case 0: $ending = "ая"; break; case 1: $ending = "ая"; break; case 2: $ending = "ое"; break; case 3: $ending = "ые"; break; default: $ending = "... само решит "; break; } printf('Добро пожаловать, уважаем%s %s',$ending,$realname); }elseif(mysql_num_rows($res)>1){ die('Гы, база допустила двух пользователей с одинаковыми логинами и паролями'); }else{ echo('пара логин/пароль неверна'); } 
  • Not really. They are rustic, easy to check yourself. Just elementary: $_SESSION[] is an array. You can simply substitute in it some key, some value and check what happens. print_r($_SESSION) to help you. - knes
  • But if I need to display the name of the unit how to do it? - k0mar
  • Vlad, will it be possible to rob a cow in your game? - Ali
  • one
    @alienator, you can. wait for updates and questions: "How to rob korovany in PHP + MySql" - knes
  • one
    Oh, yes))) Though I’m a teapot, but not like this)))) - k0mar