Solved

Creating a install file

Posted on 2004-09-19
3
165 Views
Last Modified: 2006-11-17
I want to create an install script for a little program i have.
It needs to create tables in a database
and then display a form where
db user
db name
db password
db path
default address
default zip
default zip
tax rate

on submit it would create a file with the variables set in it.

0
Comment
Question by:livegirllove
  • 2
3 Comments
 
LVL 1

Author Comment

by:livegirllove
Comment Utility
This is the file I use.  Id like to make an install form where they can enter this info and it writes it to the file after inserting the tables into the db.  
I guess Im really just asking what the best way to write a file from info submittied in a form.

thanks

<?
/*
Setup the connection to the database
I also want to put site variables here suchas
tax rate for hardware
company address for mapquest
path to client support page
driver upload paths
*/

$db_user = "####";
$db_pass = "####"; // password here
$db = "#####";
$host = "mysql.#####.com"; // if this is the same server as the web server, leave it as localhost, otherwise use mysql.webgemshosting.com
$link = mysql_connect($host,$db_user,$db_pass) or die("Database connection broken");
mysql_select_db($db,$link) or die("Database connection unavailable - ".mysql_error() );

/* Default Mapquest From Address for your driveing directions
Use a + instead of a space.  It will usually work with the spaces but Map Quest uses the Pluses
*/
$MQaddress = "33861+Calle+La+Primavera";
$MQcity = "Dana+Point";
$MQstate = "CA";
$MQzip = "92629";


/*
Hardware Tax Rate*/
$HWtaxrate = ".0775";


/*
Driver Upload Path
$driver_upload_path = "http://www.#####.org/drivers/";
*/

/*
Client Service Tag Page
$client_servicetag_page = "http://support.#####.com";
*/
?>
0
 
LVL 9

Accepted Solution

by:
techtonik earned 500 total points
Comment Utility

Can you clearify some points? In particular - the correct order of operations.

1. Create tables (i.e. access database)
2. Display form with
db user
db name
db password
db path

???

3. Process form data and write next variables to a file
default address
default zip
default zip
tax rate


--------------------------------------------------------------

The best way to store configuration I could think about is to write it into PHP file, so user can also edit it through shell.
$conffile = <<<DDR
<?php
  \$db_user = $db_user;
  // some comments

  \$db_pass = $dbpass;
  // and so on..
?>
DDR;

$f = fopen("config.php", "w");
fwrite($f, $conffile);
fclose($f);

Security warning, that after installation this file should be renamed to avoid other users overwrite config.php.
0
 
LVL 1

Author Comment

by:livegirllove
Comment Utility
thanks,
I'll try that.

Yes thats the correct order.  
make the tables
display the form
submit the form
write the submitted data to config.php
delete install.php and or rename config.php
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now