?
Solved

Creating a install file

Posted on 2004-09-19
3
Medium Priority
?
212 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

764 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