Solved

Creating a install file

Posted on 2004-09-19
3
176 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
ID: 12096651
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
ID: 12100253

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
ID: 12103488
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

867 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

12 Experts available now in Live!

Get 1:1 Help Now