I am trying to make a submit action insert data into the database with
if(isset($_POST['sendrqst'])) {
$wpdb->insert("wp_refundrequests", [
"product_name" => $name,
"product_qty" => '5',
"comment" => "something",
"customer_name" => "test",
"refund_total" => "200",
"request_date" => "2000" ,
]);
$wpdb->print_error();
}
within a different file, but while $name works everywhere else properly even outside it's own "for" statement, it won't work inside that secondary file even when included to the main page, it only prints out the name of the file itself instead of what it should which is the name of a product selected from the wpdb. The name variable comes from this:
$test = $_POST['productinfo'];
$total2 = 0;
for($i=0; $i < sizeof($test); $i++) {
list($name, $quantity, $total) = explode("|", $test[$i]);
A global variable should work inside an "if" but in this case for some reason it doesn't work even tho it works just fine outside the "if". Why is it that it does not work at all while inside this certain "if" statement