prepare("SELECT COUNT(*) AS user_count FROM {$opt["table_prefix"]}users"); $stmt->execute(); if ($row = $stmt->fetch()) { $user_count = $row["user_count"]; if ($user_count != 0) { die("Database has already been set up."); } } else { die("Database has not been created."); } if (isset($_POST["action"])) { if ($_POST["action"] == "setup") { $username = $_POST["username"]; $fullname = $_POST["fullname"]; $pwd = $_POST["pwd"]; $email = $_POST["email"]; $familyname = $_POST["familyname"]; if (trim($familyname) == "") { $familyname = "Default family"; } // 1. create the family. $stmt = dbh($opt)->prepare("INSERT INTO {$opt["table_prefix"]}families(familyname) VALUES(?)"); $stmt->bindParam(1, $familyname, PDO::PARAM_STR); $stmt->execute(); // 2. get the familyid. $stmt = dbh($opt)->prepare("SELECT MAX(familyid) AS familyid FROM {$opt["table_prefix"]}families"); $stmt->execute(); if ($row = $stmt->fetch()) { $familyid = $row["familyid"]; } else die("No family was created."); // 3. insert the user. $stmt = dbh($opt)->prepare("INSERT INTO {$opt["table_prefix"]}users(username,fullname,password,email,approved,admin,initialfamilyid) VALUES(?, ?, {$opt["password_hasher"]}(?), ?, 1, 1, ?)"); $stmt->bindParam(1, $username, PDO::PARAM_STR); $stmt->bindParam(2, $fullname, PDO::PARAM_STR); $stmt->bindParam(3, $pwd, PDO::PARAM_STR); $stmt->bindParam(4, $email, PDO::PARAM_STR); $stmt->bindParam(5, $familyid, PDO::PARAM_INT); $stmt->execute(); // 4. get the userid. $stmt = dbh($opt)->prepare("SELECT MAX(userid) AS userid FROM {$opt["table_prefix"]}users"); $stmt->execute(); if ($row = $stmt->fetch()) { $userid = $row["userid"]; } else die("No user was created."); // 5. create the membership. $stmt = dbh($opt)->prepare("INSERT INTO {$opt["table_prefix"]}memberships(userid,familyid) VALUES(?, ?)"); $stmt->bindParam(1, $userid, PDO::PARAM_INT); $stmt->bindParam(2, $familyid, PDO::PARAM_INT); $stmt->execute(); } } ?>
Thank you for setting up the Gift Registry. You may now login and begin!
Below are your configuration values. If you would like to change anything, edit config.php. Each value's purpose is described in config.php.
Testing Smarty installation... ensure the result is OK.
"; require_once(dirname(__FILE__) . "/includes/MySmarty.class.php"); $smarty = new MySmarty(); $smarty->testInstall(); ?>