diff --git a/go-form-plugin/go-form-plugin.php b/go-form-plugin/go-form-plugin.php index c7b46a8..b794c95 100644 --- a/go-form-plugin/go-form-plugin.php +++ b/go-form-plugin/go-form-plugin.php @@ -37,16 +37,10 @@ function go_form_activate() email varchar(255) DEFAULT NULL, egd_number varchar(20) DEFAULT NULL, comment text DEFAULT NULL, - created_at datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, + created_at date DEFAULT CURRENT_TIMESTAMP NOT NULL, PRIMARY KEY (id), - KEY form_id (form_id) + FOREIGN KEY (form_id) REFERENCES $forms(id) ON DELETE CASCADE ) $charset;"); - - // Add default form if none exist - $existing_forms = $wpdb->get_var("SELECT COUNT(*) FROM $forms"); - if ($existing_forms == 0) { - $wpdb->insert($forms, ['name' => 'Default Form']); - } } register_activation_hook(__FILE__, 'go_form_activate'); @@ -107,20 +101,16 @@ function go_form_handle_submission() wp_die('Security check failed'); global $wpdb; - $form_id = isset($_POST['form_id']) ? intval($_POST['form_id']) : 1; - - // Check if form exists - $form_exists = $wpdb->get_var($wpdb->prepare( - "SELECT COUNT(*) FROM {$wpdb->prefix}go_form_forms WHERE id = %d", - $form_id - )); - if (!$form_exists) { - $form_id = 1; // Fallback to default form + if (isset($_POST['form_id'])) { + $form_id = intval($_POST['form_id']); + } else { + wp_redirect($_SERVER['HTTP_REFERER']); + exit; } $rating = intval($_POST['rating']); $rank = intval($_POST['rank']); - if($rating < -900) { + if ($rating < -900) { $rating = ($rank * 100) - 900; } @@ -218,10 +208,7 @@ function go_form_delete_form() if (isset($_POST['value_one'])) { global $wpdb; $id = intval($_POST['value_one']); - if ($id > 1) { - $wpdb->delete("{$wpdb->prefix}go_form_entries", ['form_id' => $id]); - $wpdb->delete("{$wpdb->prefix}go_form_forms", ['id' => $id]); - } + $wpdb->delete("{$wpdb->prefix}go_form_forms", ['id' => $id]); } $redirect_url = add_query_arg(array('page' => 'go-form-settings', 'deleted' => 1), admin_url('admin.php')); wp_redirect($redirect_url); diff --git a/go-form-plugin/templates/table.php b/go-form-plugin/templates/table.php index fcca576..3efce3a 100644 --- a/go-form-plugin/templates/table.php +++ b/go-form-plugin/templates/table.php @@ -7,10 +7,10 @@ Club Rank EGD Number + Date Added Rating Email - Date Added Action Comment @@ -27,12 +27,12 @@ club) ?> rank]) ?> egd_number) ?> - + created_at) ?> + rating) ?> email) ?> - created_at) ?> id); ?> diff --git a/restart_wp.sh b/restart_wp.sh index 7bbdf5c..08061ef 100755 --- a/restart_wp.sh +++ b/restart_wp.sh @@ -19,7 +19,8 @@ echo "removed pods" #exit 0 # Recreate pod -podman pod create -n $POD_NAME -p 8090:80 +podman pod create -n $POD_NAME -p 8090:80 -p 3306:3306 + # Start MariaDB podman run --detach --pod $POD_NAME \ diff --git a/setup_wp.sh b/setup_wp.sh index 65ed71a..c0e5fce 100755 --- a/setup_wp.sh +++ b/setup_wp.sh @@ -25,7 +25,7 @@ podman pull docker.io/wordpress # Create a pod instead of --link. # So both containers are able to reach each others. -podman pod create -n $POD_NAME -p 8090:80 +podman pod create -n $POD_NAME -p 8090:80 -p 3306:3306 podman run --detach --pod $POD_NAME \ -e MYSQL_ROOT_PASSWORD=$DB_PASS \