47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
<?php
|
|
// ------------------------------------------------------------------------- //
|
|
// Test de connection à MySQL //
|
|
// ------------------------------------------------------------------------- //
|
|
|
|
echo "Bonjour \n";
|
|
|
|
$sql_host = "localhost";
|
|
$sql_user = "iut";
|
|
$sql_pwd = "iut";
|
|
$sql_db = "BD_TP2";
|
|
|
|
|
|
// Create connection
|
|
$conn = new mysqli($sql_host, $sql_user, $sql_pwd, $sql_db);
|
|
// Check connection
|
|
if ($conn->connect_error) {
|
|
die("Connection failed: " . $conn->connect_error);
|
|
}
|
|
echo "<br/>"."Connexion reussie :)..."."<br/>";
|
|
|
|
|
|
$nom = $_GET['login'];
|
|
$motdepasse = $_GET['motdepasse'];
|
|
//$nom = mysqli_real_escape_string($conn, $_POST['login']);
|
|
//$motdepasse = mysql_real_escape_string(($conn, $_POST['motdepasse']);
|
|
|
|
print ("nom = $nom, mdp = $motdepasse");
|
|
echo "<br/>Card number request";
|
|
|
|
|
|
//select des cartes
|
|
// on envoie la requête
|
|
//$sql ="SELECT numerocarte FROM comptes WHERE (nom = '$nom' AND motdepasse = '$motdepasse')";
|
|
$sql ="SELECT numerocarte FROM comptes WHERE (nom = '' OR 1=1)";
|
|
$req = $conn->query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
|
|
$row = $req->fetch_assoc();
|
|
echo "<br>";
|
|
echo "numero de carte = ";
|
|
echo $row['numerocarte'];
|
|
|
|
//Fermeture de la connexion
|
|
$conn->close();
|
|
?>
|
|
|
|
|