Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $conn = mysqli_connect("localhost", "root", "", "appartements");
- if(!$conn){
- die("Erreur de connexion à la base de données.");
- }
- $numero_appartement = $_POST["numero_appartement"];
- $nom_locataire = $_POST["nom_locataire"];
- $prenom_locataire = $_POST["prenom_locataire"];
- $query = "SELECT * FROM appartement WHERE numero_appartement = '$numero_appartement'";
- $result = mysqli_query($conn, $query);
- if(mysqli_num_rows($result) > 0){
- echo "existe";
- }
- else{
- $query = "INSERT INTO appartement (numero_appartement, nom_locataire, prenom_locataire) VALUES ('$numero_appartement', '$nom_locataire', '$prenom_locataire')";
- if(mysqli_query($conn, $query)){
- echo "succes";
- }
- else{
- echo "erreur";
- }
- }
- mysqli_close($conn);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement