Friday, August 17, 2012

PHP Installer

PHP Installer

Some PHP applications need to have installer to install databases, in order to install database and tables provided by php applications we have to input our password,user name,database name etc.which are to be written into the file mostly name as config.php to install the tables.You need to post your following details to to be written into confg.php by using bellow table.


Input Host Name
Input Password
Input Database Name
Input Table Name
Click To Install The Application


<table bgcolor=#445275 align="center">
<form action="install.php" method="post">
<tr bgcolor=#cfd9f5><td>Input Host Name</td><td><input type="text" name="host"></td></tr>
<tr bgcolor=#cfd9f5><td>Input Passward</td><td><input type="text" name="pward"></td></tr>
<tr bgcolor=#cfd9f5><td>Input Database Name</td><td><input type="text" name="dbname"></td></tr>
<tr bgcolor=#cfd9f5><td>Input Table Name</td><td><input type="text" name="tbname"></td></tr>
<tr bgcolor=#cfd9f5><td>Click To Inatall The Application</td><td><input type="submit" value="Install"></td></tr>
</form>
</table>

install.php will write the above information into config.php shown 2nd bellow


<?php
$host=$_POST['host'];
$pward=$_POST['pward'];
$dbname=$_POST['dbname'];
$tbname=$_POST['tbname'];
$myFile = "config.php";
$fh = fopen($myFile, 'w') or die("can't open file");
$tag1="<?php";
$host="\$host='$host';\n";
$pward="\$pward='$pward';\n";
$dbname="\$dbname='$dbname';\n";
$tbname="\$tbname='$tbname';\n";
$tag2="?>";
fwrite($fh, $tag1);
fwrite($fh, $host);
fwrite($fh, $pward);
fwrite($fh, $dbname);
fwrite($fh, $tbname);
fwrite($fh, $tag2);
fclose($fh);
header("location: config.php");

?>

config.php :-Empty file created to write above details bellow it has written with the data i entered



<?php
$host='localhost';
$pward='novotelwebinfoplus';
$dbname='infoplus';
$tbname='wintable';
?>

No comments:

Post a Comment