<?php
/*
Plugin Name: Form Data
Description: Form Data Plugin
version: 1.3
Author: indrajeet
*/
register_activation_hook(__FILE__,'form_data_activate');
register_deactivation_hook(__FILE__,'form_data_deactivate');
function form_data_activate() {
//echo "Activate";
/*global $wpdb;
global $table_prefix;
$table = $table_prefix."form_data1";
//$table = $table_prefix.'form_data1';
$sql = "CREATE TABLE $table (id int(11) NOT NULL,
name varchar(500) NOT NULL ) ENGINE = InnoDB DEFAULT CHARSET
= latin1; ALTER TABLE $table ADD PRIMARY KEY('id'); ALTER TABLE $table MODIFY 'id' int(11) NOT NULL AUTO_INCREMENT;";*/
/*$sql1 = "CREATE TABLE $table ('id' int(11) NOT NULL, 'name' varchar(500) NOT NULL) ENGINE = InnoDB DEFAULT CHARSET
= latin; ALTER TABLE $table ADD PRIMARY KEY('id'); ALTER TABLE $table MODIFY 'id' int(11) NOT NULL AUTO INCEREMENT ";
*/
// correct command for creating table in database
global $wpdb;
$table_name = $wpdb->prefix . 'form_data11';
$sql = "CREATE TABLE $table_name (
id mediumint(9) unsigned NOT NULL AUTO_INCREMENT,
title varchar(50) NOT NULL,
structure longtext NOT NULL,
author longtext NOT NULL,
PRIMARY KEY (id));";
// $wpdb->query($sql);
}
function form_data_deactivate() {
global $wpdb;
global $table_prefix;
$table = $table_prefix.'indrajeet';
$sql = "DROP TABLE $table";
//$wpdb->query($sql);
}
add_action('admin_menu','form_data_menu');
function form_data_menu(){
add_menu_page('Form Data','Form Data',8,__FILE__,'form_data_list');
}
add_shortcode('form_data_list_shortcode','form_data_list');
// use this shortcode for page display [form_data_list_shortcode]
function form_data_list(){
include('form_data_list.php');
}
?>