Code PHP :
<?php
session_start();
define('URL_SUCCES', 'http://www.spacebattle.redby.fr/gameindex.php');
define('URL_ECHEC', 'http://www.spacebattle.redby.fr/login.html?erreur=1');
$loginOK = false;
if ( isset($_POST) && (!empty($_POST['login'])) && (!empty($_POST['password'])) ) {
extract($_POST);
$db = mysql_connect('sql.redby.info', 'spacebattle0', '356574') or die(header("Location: URL_ECHEC");
mysql_select_db('spacebattle0',$db) or die(header("Location: URL_ECHEC");
$sql = "SELECT pseudo, mot_de_passe from game where pseudo = '".addslashes($login)."'";
$req = mysql_query($sql) or die(header("Location: URL_ECHEC");
if (mysql_num_rows($req) > 0) {
$data = mysql_fetch_assoc($req);
if ($password == $data['mot_de_passe']) {
$loginOK = true;
}
}
}
if ($loginOK) {$_SESSION['pseudo'] = $_POST['login'];
header("Location: URL_SUCCES"); }
else {header("Location: URL_ECHEC"); } ?>