Я пытаюсь подключить свою форму HTML к базе данных MySQL, но продолжаю получать ошибку 405, может ли кто -нибудь помочь? Я использую phpmyadmin, и я не знаю, может ли что -то не настроено правильно. < /P>
php: < /p>
// This script processes the form submission from the recipe submission page
$recipeName = $_POST['name'];
$author = $_POST['author'];
$description = $_POST['description'];
$ingredients = $_POST['ingredients'];
$instructions = $_POST['instructions'];
$prepTime = filter_input(INPUT_POST, 'prep_time', FILTER_VALIDATE_INT); // Validate prep_time as an integer
$cookTime = filter_input(INPUT_POST, 'cook_time', FILTER_VALIDATE_INT); // Validate cook_time as an integer
$servings = filter_input(INPUT_POST, 'servings', FILTER_VALIDATE_INT); // Validate servings as an integer
// Database connection
$host = 'localhost';
$dbname = 'recipes';
$username = 'root';
$password = '';
mysqli_connect($host, $username, $password, $dbname);
if (mysqli_connect_errno()) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "INSERT INTO recipes (name, author, description, ingredients, instructions, prep_time, cook_time, servings) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
die("SQL statement failed: " . mysqli_error($conn));
}
mysqli_stmt_bind_param($stmt, "sssssiii", $recipeName, $author, $description, $ingredients, $instructions, $prepTime, $cookTime, $servings);
mysqli_stmt_execute($stmt);
echo "Recipe submitted successfully!";
?>
< /code>
``
html form: < /p>
Recipe Name:
Family Name (Deegan, Bresee, etc.):
Description:
Recipe Type
Breakfast
Lunch
Dinner
Side
Appetizer
Snack
Dessert
Ingredients:
Instructions:
Preparation Time (minutes):
Cooking Time (minutes):
Servings:
Submit Recipe
Clear Form
< /code>
Я попытался очистить кэш и перезапуск, все еще получая ошибку. Я попытался искать гиды на YouTube, но я чувствую, что что -то здесь упускаю. Любая помощь ценится .....
Подробнее здесь: https://stackoverflow.com/questions/795 ... re-out-why