Example #1
0
*/
$DB = new Database();
//a new connection to the database
$DB->table = strtolower($_POST['company'] . '_' . $folder_name);
//set table name
$table = $DB->table;
//get table name
if (!$DB->TableExists($table)) {
    //sql to create a table
    $sql = "CREATE TABLE `{$table}` (          \n\t\tId int(7) NOT NULL AUTO_INCREMENT,\n\t\tfirst_name varchar(50) NOT NULL,\n\t\tlast_name varchar(50) NOT NULL,\n\t\tmiddle_name varchar(50),\n\t\tname varchar(150),\n\t\temail varchar(50) NOT NULL,\n\t\ttelephone varchar(15),\n\t\ttimezone tinyint(4), \n\t\tgender varchar(20),\n\t\tlocale varchar(50),\n\t\tlink varchar(50),\n\t\tdesktop tinyint(1),\n\t\tmobile tinyint(1),\n\t\tnon_fb tinyint(1),\n\t\tPRIMARY KEY (Id),\n\t\tUNIQUE id (Id)\n\t)";
    $DB->MakeTable($sql);
} else {
    $title = 'Error';
    $html .= "<br>That table already exists";
    $mySmarty->assign('html', $html);
    $mySmarty->assign('success', $success);
    $mySmarty->assign('title', $title);
    $mySmarty->display("install.html");
    exit;
}
$DB->CloseDB();
//close database connection
$title = 'Success';
//the title of the html page
$success = true;
//no errors have occured up to this point. we have had a successfull installation
$html .= "To add the app to your Facebook page<br><hr>\nPlease copy the link below into your browser search bar then hit enter.<br>\nMAKE SURE YOU ARE LOGGED IN ON FACEBOOK<br>\nhttps://www.facebook.com/dialog/pagetab?app_id=" . $_POST['AppID'] . "&redirect_uri=https://www.naddesign.ca/fb_dev_app/FB_Contests/" . $_POST['company'] . '/' . $date;
$mySmarty->assign('title', $title);
$mySmarty->assign('html', $html);
$mySmarty->assign('success', $success);
$mySmarty->display("install.html");