okay so i wanna log in as user and admin, my user table is called "sollicitant" and my admin is "bedrijf" (this is dutch lol sorry). the code i have right now works for only 1 table but how can i have a sql query that looks in both tables to log in?
<?php
if(isset($_POST['email'])) {
$inputEmail = htmlspecialchars($_POST['email']);
$inputWachtwoord = htmlspecialchars($_POST['wachtwoord']);
$servername = "localhost";
$databasename = "vacaturebank.";
$username = "root";
$password = "";
try {
$conn = new PDO("mysql:host=$servername; dbname=$databasename", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
return;
}
try {
$stmt = $conn->prepare("SELECT * FROM sollicitant WHERE email = '$inputEmail'");
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
$row = $stmt->fetch();
$rowCount = $stmt->rowCount();
if ($rowCount) {
if ($inputWachtwoord == $row['wachtwoord']) echo "<br/>Successvol ingelogd";
else echo "<br/>Gebruikersnaam en wachtwoord komen niet overeen.";
header("Location: inloggen.html");
} else {
echo "<br/>Login failed, no record found";
}
}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
$conn = null;
session_start();
$_SESSION["login"] = true;
$_SESSION["email"] = $inputEmail;
}
?>