-1

i'm having a problem with my connexion.php Even when I enter something in input my connexion.php tell me to insert something. I don't know where's the error...

My inputs :

input type="text" class="form-control" id="identifiant" required data-validation-required-message="Entrer un identifiant."

input type="password" class="form-control" id="mdp" required data-validation-required-message="Entrer un mot de passe."

Here is my php :

<?php

$db = mysql_connect('localhost', 'root', 'root'); 
mysql_select_db('Projet',$db); 

if(empty($_POST['identifiant']) && empty($_POST['mdp'])) {
    echo "Il manque des informations veuillez remplir les champs.";
}
else{
    $_POST['mdp'] = hash("md5", $_POST['mdp']);
      extract($_POST);

      $sql = "select Password from User where Username='".$identifiant."'";
      $req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());

      $data = mysql_fetch_assoc($req);

    if($data['Password'] != $mdp) {
        echo '<div class="alert alert-dismissable alert-danger">
        <button type="button" class="close" data-dismiss="alert">x</button>
        <strong>Oh Non !</strong> Mauvais login / password. Merci de recommencer !
        </div>';
    }
    else {
        session_start();
        $_SESSION['Username'] = $identifiant;

        echo '<div class="alert alert-dismissable alert-success">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>Yes !</strong> Vous etes bien logué, Redirection dans 5 secondes ! <meta http-equiv="refresh" content="5; URL=dashboard">
        </div>';
    }
}

?>

FlorianSL
  • 89
  • 1
  • 9
  • Add `error_reporting(E_ALL); ini_set('display_errors', -1);` to the top of the php part. This will display all the errors. Also stop using the `mysql_*` extension as it is deleted as of PHP 7.0 I don't know what version of PHP you are using you can check this with `phpinfo();` or `echo 'Current PHP version: ' . phpversion();` – BRoebie Jan 22 '16 at 10:31
  • 3
    Don't use `mysql_*` functions, they are deprecated as of PHP 5.5 and are removed altogether in PHP 7.0. Use `mysqli` or `PDO` instead. – Rajdeep Paul Jan 22 '16 at 10:34
  • Ok thank you, i'll do that – FlorianSL Jan 22 '16 at 10:59

1 Answers1

2

You need to add "name" attribute in your input tags..

<input type="text" class="form-control" id="identifiant" name="identifiant" required data-validation-required-message="Entrer un identifiant." />

<input type="password" class="form-control" id="mdp" name="mdp" required data-validation-required-message="Entrer un mot de passe." />
Edwin Alex
  • 5,118
  • 4
  • 28
  • 50