01hanstu Posted November 8, 2009 Share Posted November 8, 2009 Hi, I am wonder if someone can help. I want to be able to complete a form, the submit it and all of the information will save in a settings.php file. i.e. company_txt (text field) will save to variable $Company which is set as empty in the setting.php file will look like this (below) just empty until the form has been completed. <?php &company = ""; &var1= ""; &var2= ""; &var3= ""; ?> Thanks Stuart Quote Link to comment Share on other sites More sharing options...
chauffeur Posted November 9, 2009 Share Posted November 9, 2009 look up my post here:- http://www.phpfreaks.com/forums/index.php/topic,276108.0.html with minor mods, you can write what you need to write to any file, you name it. i would suggest you make sure you make the script go to a new file name each time it executes or it'll over write the same file each time. Quote Link to comment Share on other sites More sharing options...
bob2588 Posted November 9, 2009 Share Posted November 9, 2009 This is a script that i made to make a file called db.php with some mods it will serv your needs <?php $error = false; if(isset($_POST['Submit'])){ if($_POST['host'] =="") { echo"Please Fill Out the Host Filed"; $error = true; } if($_POST['user'] =="") { echo"<br>Please fill Out the Username Filed"; $error = true; } if($_POST['pass'] =="") { echo"<br>Please Fill Out the Password"; $error = true; } if($_POST['db_name'] =="") { echo"<br>please fill Out the Databases name"; $error = true; } if ($error){ exit(); } $db_host=$_POST['host']; $db_user=$_POST['user']; $db_pass=$_POST['pass']; $db_dbname=$_POST['db_name']; $file = 'db.php'; $host = '$host=" '.$db_host .' ";' ."\n"; $user = '$user="'. $db_user .' ";' ."\n"; $pass = '$pass=" '. $db_pass .' ";' ."\n"; $db_name = '$$db_name="'. $db_dbname .' ";' ."\n"; $query ='$link = mysql_connect($host, $user, $pass);' ."\n"; $db = 'mysql_select_db($db_name);' ."\n"; file_put_contents($file, $host); file_put_contents($file, $user, FILE_APPEND); file_put_contents($file,$pass, FILE_APPEND); file_put_contents($file,$db_name, FILE_APPEND); file_put_contents($file,$query, FILE_APPEND); file_put_contents($file,$db, FILE_APPEND); echo"File Done <br> $db_host"; } else { echo"<form name='form1' method='post' action=''> <table width='259' height='192' border='1' align='center'> <tr> <td colspan='2'>Data Base Conntection </td> </tr> <tr> <td width='140'>Host</td> <td width='103'><label> <input type='text' name='host' id='host'> </label></td> </tr> <tr> <td>Username</td> <td><label> <input type='text' name='user' id='usern'> </label></td> </tr> <tr> <td>Password</td> <td><label> <input type='text' name='pass' id='pass'> </label></td> </tr> <tr> <td>Database Name</td> <td><label> <input type='text' name='db_name' id='db_name'> </label></td> </tr> <tr> <td colspan='2' align='center'><label> <input type='submit' name='Submit' id='Submit' value='Submit'> </label></td> </tr> </table> <form name='form1' method='post' action=''> </form>"; } ?> Enjoy bob Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.