chris270 Posted May 12, 2010 Share Posted May 12, 2010 Okay what im gonna do, is to make a php site that creates a .ini file.. Ive looked all over google trying to find this but it just can't, so if someone could help me do this it would be really nice.. The php form should have the following: Account Name: Password: (and a submit button) Then when you press Submit, it should create a file called: [what you entered in account name:].ini and inside the file it should be like this: [account] password=[what you entered in password form] here are some screens on how i want it to look like: Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/201479-need-help/ Share on other sites More sharing options...
chris270 Posted May 12, 2010 Author Share Posted May 12, 2010 i really need help for this fast, so if someone could guide me it would be so nice! Quote Link to comment https://forums.phpfreaks.com/topic/201479-need-help/#findComment-1057036 Share on other sites More sharing options...
Muddy_Funster Posted May 12, 2010 Share Posted May 12, 2010 [*]Where are you planing on having these ini files stored? [*]Do you know how utterly insecure it is to store account information in unencrypted flat files [*]Have you heard of MySQL? Quote Link to comment https://forums.phpfreaks.com/topic/201479-need-help/#findComment-1057069 Share on other sites More sharing options...
phpchamps Posted May 12, 2010 Share Posted May 12, 2010 <?php function write_php_ini($array, $file) { $res = array(); foreach($array as $key => $val) { if(is_array($val)) { $res[] = "[$key]"; foreach($val as $skey => $sval) $res[] = "$skey = ".(is_numeric($sval) ? $sval : '"'.$sval.'"'); } else $res[] = "$key = ".(is_numeric($val) ? $val : '"'.$val.'"'); } safefilerewrite($file, implode("\r\n", $res)); } ////// function safefilerewrite($fileName, $dataToSave) { if ($fp = fopen($fileName, 'w')) { $startTime = microtime(); do { $canWrite = flock($fp, LOCK_EX); // If lock not obtained sleep for 0 - 100 milliseconds, to avoid collision and CPU load if(!$canWrite) usleep(round(rand(0, 100)*1000)); } while ((!$canWrite)and((microtime()-$startTime) < 1000)); //file was locked so now we can store information if ($canWrite) { fwrite($fp, $dataToSave); flock($fp, LOCK_UN); } fclose($fp); } } ?> <form name="frm_generate_file" method="post" action=""> <input type="text" name="txt_name" value=""> <input type="password" name="pwd_password" value=""> <input type="submit" name="submit" value="submit"> </form> <?php if(!empty($_POST)){ $arr['Account'] = $_POST['txt_name']; $arr['password'] = $_POST['pwd_password']; $filename = $arr['Account'].'.ini'; write_php_ini($arr, $filename); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/201479-need-help/#findComment-1057075 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.