[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 218
  • Last Modified:

Creating a install file

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
livegirllove
Asked:
livegirllove
  • 2
1 Solution
 
livegirlloveAuthor Commented:
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
 
techtonikCommented:

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
 
livegirlloveAuthor Commented:
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now