papillonstudios Posted July 19, 2009 Share Posted July 19, 2009 I want to create a new an install script for my CMS, but im not sure how i should go about it. heres my idea. I have a folder within the CMS called install, and in there i have index.php, and a folder called steps. Then in the index.php file i have a an if statement of some sort that checks a variable called $step, to see if it's value is 1 - 3 or how ever many steps i have. Then displays the appropiate page that corresponds with the value of $step. for example $step = 2 (displays page 2 from the steps folder. and so on is this a system if not how could i change it. Or even suggest how i could do it a different way. Quote Link to comment Share on other sites More sharing options...
ignace Posted July 19, 2009 Share Posted July 19, 2009 There are a few ways you can do it, you could also instead of using numbers name each step by what they do (e.g. installdb): $page = $_GET['page']; $directory = realpath('/relative/path/to/steps/directory'); $file = implode(DIRECTORY_SEPARATOR, array($directory, $page . '.ext')); if (!$page || !ctype_alpha($page) || !file_exists($file)) { //invalid } require($file); Or as you are using a wizard, you could use: http://www.phpfreaks.com/forums/index.php/topic,261112.msg1229397.html#msg1229397 Quote Link to comment Share on other sites More sharing options...
papillonstudios Posted July 20, 2009 Author Share Posted July 20, 2009 ok i got ya i will post what i decide to do i posted on another forum and they said Just create an install.php file with all of the html code in there, with each respective section within if/else statements. For example: if (!isset($_POST['step']) || empty($_POST)) { [step one code here] } else if (isset($_POST['step']) && $_POST['step'] == '2') { [step two code here] } etc. Quote Link to comment Share on other sites More sharing options...
mike12255 Posted July 20, 2009 Share Posted July 20, 2009 theres a million ways to do it that would work aswell, decide which way you like the best Quote Link to comment Share on other sites More sharing options...
papillonstudios Posted July 21, 2009 Author Share Posted July 21, 2009 i decided to go with the code that i posted in my last reply. So i started coding and got the first step of installing my cms complete but i got an error and i dont know what the hell the error shows up. heres the error Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in step1.php on line 98 my code <?php //If the form hasn't been submitted, show it. if (!$_POST['post']) { ?> <form method="post"> <p>Host <input type="text" class="input" name="host" /></p> <p>Database Name <input type="text" class="input" name="dbname" /></p> <p>Database Username<input type="text" class="input" name="dbuser" /></p> <p>Database Password<input type="text" class="input" name="dbpass" /></p> <p><input type="submit" class="input" name="submit" value="Continue ->" /></p> </form> <?php } //Or else it has been submitted... else { //Get information from the forms secure it all. $host= secure($_POST['host']); $dbname = secure($_POST['dname']); $dbuser = secure($_POST['dbuser']); $dbpass = secure($_POST['dbpass']); $connect = mysql_connect($host,$dbuser,dbpass); if ($connect) { $select = mysql_select_db ($dbname); if ($select) { $users = "CREATE TABLE `users` ( `id` int(5) NOT NULL auto_increment, `username` varchar(30) NOT NULL, `password` varchar(255) NOT NULL, `email` varchar(50) NOT NULL, `location` varchar(50) NOT NULL, `aim` varchar(30) NOT NULL, `msn` varchar(30) default NULL, `gtalk` varchar(30) NOT NULL, `ip` varchar(30) NOT NULL, `signup` varchar(30) NOT NULL, `membergroup` varchar(30) NOT NULL, `bio` varchar(400) NOT NULL, PRIMARY KEY (`id`) );"; $permissions = " CREATE TABLE `permissions` ( mg_id INT(10) NOT NULL AUTO_INCREMENT, mg_name VARCHAR(50) NOT NULL, editprofile INT(1) NOT NULL, viewprofile INT(1) NOT NULL, admin INT(1) NOT NULL, moderate INT(1) NOT NULL, PRIMARY KEY (`mg_id`) );"; $addperm = " INSERT INTO `permissions` (`mg_id`, `mg_name`, `editprofile`, `viewprofile`, `admin`, `moderate`) VALUES (1, 'user', 1, 1, 0, 0), (2, 'admin', 1, 1, 1, 1), (3, 'guest', 0, 0, 0, 0); (4, 'mod', 1, 1, 0, 1); "; $info = "CREATE TABLE `info` ( `id` INT( 11 ) NOT NULL , `version` VARCHAR( 50 ) NOT NULL , `sitename` VARCHAR( 100 ) NOT NULL , `siteurl` VARCHAR( 100 ) NOT NULL , `sitedesc` TEXT NOT NULL , `aemail` VARCHAR( 300 ) NOT NULL , `emailink` VARCHAR( 300 ) NOT NULL , PRIMARY KEY ( `id` ) ) ENGINE = MYISAM"; $news "CREATE TABLE `news` ( `id` INT( 11 ) NOT NULL AUTO_INCREMENT , `title` VARCHAR( 50 ) NOT NULL , `username` VARCHAR( 50 ) NOT NULL , `date` TIMESTAMP NOT NULL `body` TEXT NOT NULL , PRIMARY KEY ( `id` ) ) ENGINE = MYISAM"; $nav = "CREATE TABLE `nav` ( `id` INT( 11 ) NOT NULL AUTO_INCREMENT , `linkname` VARCHAR( 50 ) NOT NULL , `url` VARCHAR( 100 ) NOT NULL , PRIMARY KEY ( `id` ) ) ENGINE = MYISAM"; $donwloads = "CREATE TABLE `downloads` ( `id` INT( 11 ) NOT NULL AUTO_INCREMENT , `name` VARCHAR( 100 ) NOT NULL , `url` VARCHAR( 100 ) NOT NULL , `date` VARCHAR( 20 ) NOT NULL , `username` VARCHAR( 50 ) NOT NULL , PRIMARY KEY ( `id` ) ) ENGINE = MYISAM"; $games = "CREATE TABLE `games` ( `id` INT NOT NULL AUTO_INCREMENT , `name` VARCHAR( 20 ) NOT NULL , `source` VARCHAR( 100 ) NOT NULL , `gamedesc` TEXT NOT NULL , PRIMARY KEY ( `id` ) ) ENGINE = MYISAM "; }else{ echo "Error message = ".mysql_error(); }else{ echo "Error message = ".mysql_error(); } $update = mysql_query("UPDATE info SET sitename = '$sitename', siteurl = '$siteurl', sitedesc = '$sitedesc', aemail = '$aemail' WHERE id = '1'"); //A query to update everything } ?> the troubled line(according to the error)(where i placed the bold tags is line 98 ) $news "CREATE TABLE `news` ( `id` INT( 11 ) NOT NULL AUTO_INCREMENT , `title` VARCHAR( 50 ) NOT NULL , `username` VARCHAR( 50 ) NOT NULL , `date` TIMESTAMP NOT NULL `body` TEXT NOT NULL , PRIMARY KEY ( `id` ) [b]) ENGINE = MYISAM";[/b] Quote Link to comment Share on other sites More sharing options...
ignace Posted July 21, 2009 Share Posted July 21, 2009 $news "CREATE TABLE `news` ( should be: $news = "CREATE TABLE `news` ( hence the = Quote Link to comment Share on other sites More sharing options...
papillonstudios Posted July 21, 2009 Author Share Posted July 21, 2009 OMG I Cant believe i didn't see that thanks a million Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.