eaglelegend Posted October 18, 2008 Share Posted October 18, 2008 Hi guys, I have been littrelly dieing to try and work out how to make my code simply install it self on my users server, however I just can never tell how. I guessed it must get users information including the database login etc. then saves it, then installs the database dump with their information provided. also I was rather hoping to be able to do the opposite - for upgrading or such? Thanks, Mark Link to comment https://forums.phpfreaks.com/topic/129012-incode-script-setup/ Share on other sites More sharing options...
eaglelegend Posted October 18, 2008 Author Share Posted October 18, 2008 My question is, How do I create a "auto-setup" for a user? Link to comment https://forums.phpfreaks.com/topic/129012-incode-script-setup/#findComment-668798 Share on other sites More sharing options...
redarrow Posted October 18, 2008 Share Posted October 18, 2008 http://www.php-mysql-tutorial.com/create-mysql-database-with-php.php <?php include 'config.php'; include 'opendb.php'; $query = 'CREATE DATABASE phpcake'; $result = mysql_query($query); mysql_select_db('phpcake') or die('Cannot select database'); $query = 'CREATE TABLE contact( '. 'cid INT NOT NULL AUTO_INCREMENT, '. 'cname VARCHAR(20) NOT NULL, '. 'cemail VARCHAR(50) NOT NULL, '. 'csubject VARCHAR(30) NOT NULL, '. 'cmessage TEXT NOT NULL, '. 'PRIMARY KEY(cid))'; $result = mysql_query($query); include 'closedb.php'; ?> Link to comment https://forums.phpfreaks.com/topic/129012-incode-script-setup/#findComment-668809 Share on other sites More sharing options...
redarrow Posted October 19, 2008 Share Posted October 19, 2008 better example just post your database name and password...... <?php // if we post from a form.... if(isset($_POST['submit'])){ // posting name and password.... $database_name=trim($_POST['database_name']); $database_password=trim($_POST['database_password']); // if condition meets from the url...... if($_GET['cmd']=="create_database"){ // connect database.... $sql=mysql_connect("192.168.0.10", "$database_name","$database_password"); // create database info.... $create_database="CREATE DATABASE database_example"; $res1=mysql_query($create_database)or die('YOU HAVE A CREATE DATABASE ERROR:'. mysql_error()); $sel="USE database_example"; mysql_query($sel); $create_database_table='CREATE TABLE redarrow(id SMALLINT UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT PRIMARY KEY,name VARCHAR(20) NOT NULL,age INT NOT NULL,message TEXT NOT NULL);'; $res2=mysql_query($create_database_table)or die('YOU HAVE A DATABASE TALBE ERROR'.mysql_error()); // select database to insetr info.... $res=mysql_select_db("database_example", $sql); $insert_database="INSERT INTO `redarrow`(`id`,`name`,`age`,`message`)VALUES('0001','redarrow','34','I LOVE LEARNING MYSQL AND PHP')"; $res3=mysql_query($insert_database)or die('YOU HAVE A DATABASE INSERT ERROR'.mysql_error()); // if info in the database show it..... if($res3){ $show_entry="SELECT * FROM redarrow"; $res4=mysql_query($show_entry)or die('YOU HAVE A SELECT DATABASE ERROR'.mysql_error()); while($select_info=mysql_fetch_assoc($res4)){ echo "The database id is: ".$select_info['id']." <br> My name is:".$select_info['name']." <br> My old age is ".$select_info['age']." <br> ".$select_info['message']." "; exit; } } }else{ echo"DONT TRY AND HACK ME BOY!!!!!!!!!!!!!"; unset($_SESSION['database_name']); unset($_SESSION['database_password']); session_destroy(); } }else{ echo"fill in the correct info!!!!!!!!!!!!!"; unset($_SESSION['database_name']); unset($_SESSION['database_password']); session_destroy(); } ?> <center> <form method="POST" action="<?php $_SERVER['PHP_SELF'];?>?cmd=create_database"> <br><br> Database username! <br> <input type="text" name="database_name"> <br><br> Database Password <br> <input type="text" name="database_password"> <br><br> <input type="submit" name="submit" value="create database!"> </form> </center> Link to comment https://forums.phpfreaks.com/topic/129012-incode-script-setup/#findComment-668884 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.