I have created a PHP program that provides customised output based upon user input entered in HTML contact form. The HTML form & PHP output is working fine. However, when I am trying to save the data in WP database, I am not able to see any response. I have created 'wp_mealplanner' table in the database and when i am trying to manually save the data through PHPMYADMIN, it is working fine. Please let me know where am I going wrong. I am not getting any error message.
Please find the code below:
<?php
/* Template Name: CustomPageT1 */
$region = $_POST['Region'];
$name = $_POST['user_name'];
$email = $_POST['user_email'];
$phone = $_POST['user_phone'];
$Click_here_to_start_your_download = 'https://mydailysugar.info/wp-
content/uploads/2019/09/Blood-Glucose-Chart-A4-1.pdf';
switch ($region )
{
case 'North':
echo "<a href='$Click_here_to_start_your_download'>Click here to start your
download</a>";
die;
case 'South':
echo "<a href='$Click_here_to_start_your_download'>Click here to start your
download</a>";
die;
case 'East':
echo "<a href='$Click_here_to_start_your_download'>Click here to start your
download</a>";
die;
case 'West':
echo "<a href='$Click_here_to_start_your_download'>Click here to start your
download</a>";
die;
}
?>
<?php
if ( isset( $_POST['SUBMIT'] ) )
{
global $wpdb;
$table ='wp_mealplanner';
$data = array('name' => $_POST['user_name'],'email' =>
$_POST['user_email'],'phone' =>
$_POST['user_phone']);
$format = array('%s','%s','%d');
$wpdb->insert( $table, $data, $format );
}
?>
<html>
<head>
<title> Meal Planner </title>
</head>
<body>
<form method='POST'>
<p>Name</p> <input type='text' name='user_name'>
<p>Email</p> <input type='text' name='user_email'>
<p>Phone</p> <input type='text' name='user_phone'>
<p>Dropdown Box</p>
<select name='Region' size='1'>
<option value='North'>North
<option value='South'>South
<option value='East'>East
<option value='West'>West
</select>
<br />
<input type='submit' name ='submit' value='SUBMIT'><input
type='reset'
value='CLEAR'>
</form>
</body>
</html>