plugins - No result after wpdb->insert

admin2025-06-03  3

I have implemented my own plugin (PHP file). It contains a form with questions with input type = radio. I want to submit the answers and load them into the database. My action is calling another PHP file (which gets found properly). However, the browser cannot load anything. After hours of research I found out that my wpdb query stops the procedure, but what am I doing wrong?

<?php

//Collecting info
$name = $_POST['name'];
$movie = $_POST['movie'];

//Check if we have all input fields (function does not need check)
if(empty($name)){
    die("Please Choose A Name! <a href='javascript:history.back()'>Back</a><br>");
}
if(empty($movie)){
    die("Please Choose your favourite Movie! <a href='javascript:history.back()'>Back</a><br>");
}

//Load answers to database
global $wpdb;
$table = $wpdb->prefix . 'themovies';
$wpdb->insert($table, array('Name' => $name, 'Movie' => $movie), array('%s', '%s'));

if($insert == true){
    header("location: thankyou.php");
    exit;
}
else
{
    echo "Error";
}
?>
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748934633a314952.html

最新回复(0)