I got this code from php builder, and I've added a couple of things.
What I'd like to do is basically this,
I'd like to write the following into the file
===============================
<?
$db_host = "localhost";
$db_user = "db_username";
$db_pass = "db_password";
$db_name = "db_name";
?>
As you can see there are quotation marks, and I was wondering how I'd write the quotation marks using the bottom file.
I'm hoping someone can help me.
Thanks.
<?php
if(isset($_POST['submit']))
{
$file = $_POST['file'];
$str_tofile = "$db_host=".$_POST['db_host']."\n";
$str_tofile .= "$db_name=".$_POST['db_name']."\n";
$str_tofile .= "$db_user=".$_POST['db_user']."\n";
$str_tofile .= "$db_pass=".$_POST['db_pass']."\n";
$handle = fopen($file.".php" , "w");
fwrite($handle,$str_tofile);
fclose($handle);
echo "Please, delete this file.";
}
else
{
print "<form method=post action=$PHP_SELF>";
print "<table border=0 cellpadding=0 cellspacing=0>";
print "<tr><td>MySQL Host</td><td><input name=db_host type=text></td></tr>";
print "<tr><td>Database Name</td><td><input name=db_name type=text></td></tr>";
print "<tr><td>Username</td><td><input type=text name=db_user></td></tr>";
print "<tr><td>Password</td><td><input type=text name=db_pass></td></tr>";
print "<tr><td>File Name</td><td><input type=text name=file></td></tr>";
print "<tr><td> </td><td><input type=submit name=submit value=Create></td></tr>";
print "</table>";
print "</form>";
}
?>