I’ve got an HTTP ERROR 500 after the registration in index.php using PHP 8.3.12 and MySQL 9.0.1, i’ve made 1 file and folder with 2 files:
index.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
</head>
<body>
<form action="./php/register.php" method="POST">
<h2>Registrati</h2>
<div>
<label for="email">Email</label>
<input type="email" name="email" id="email">
</div>
<div>
<label for="username">Username</label>
<input type="text" name="username" id="username">
</div>
<div>
<label for="password">Password</label>
<input type="password" name="password" id="password">
</div>
<input type="submit" value="invia">
</form>
</body>
</html>
Folder php:
register.php
<?php
require_once('./config.php');
$email = $connessione->real_escape_string($_POST['email']);
$username = $connessione->real_escape_string($_POST['username']);
$password = $connessione->real_escape_string($_POST['password']);
$sql = "INSERT INTO utenti (email, username, password) VALUES ('$email', '$username', '$password')";
if ($connessione->query($sql) === true) {
echo "registrazione avvenuta";
} else {
echo "errore registrazione $sql" . $connessione->error;
}
?>
config.php
<?php
$host = "127.0.0.1";
$user = "root";
$password = "rootroot";
$db = "testMySQL";
$connessione = new mysqli($host, $user, $password, $db);
if ($connessione === false) {
die("errore" . $connessione->connect_error);
}
?>
the connection in config.php with the database went smoothly
Ive tried to:
Change in register.php the
require_once('./config.php');
into
require_once('./php/config.php');
but still not working