1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| public function loginAction()
{
$session = new Session ();
$session->start();
$request = Request::createFromGlobals();
$login = $request->request->get('_username');
\mysql_connect('localhost', 'root','') or die('Erreur de connexion SQL');
\mysql_select_db('test') or die('Erreur de connexion à la bdd');
$req = mysql_query("SELECT nom FROM user WHERE username = '$login'");
$rep = mysql_fetch_assoc ($req);
$session->set('nom', $rep['nom']);
// get the login error if there is one
if ($this->container->get('request')->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
$error = $this->container->get('request')->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
} else {
$error = $this->container->get('request')->getSession()->get(SecurityContext::AUTHENTICATION_ERROR);
}
return $this->container->get('templating')->renderResponse('FormLoginBundle:Login:login.html.twig', array(
// last username entered by the user
'last_username' => $this->container->get('request')->getSession()->get(SecurityContext::LAST_USERNAME),
'error' => $error,
));
} |