Solved

Creating a install file

Posted on 2004-09-19
3
206 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 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

705 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