gangwarfare.net Posted August 16, 2006 Share Posted August 16, 2006 im new to php, and im trying to make a few scripts for my site,im tryin to write to a file<?php$information = "blah blah";$handle = fopen('$username.php', 'w+');fwrite($handle, $information);?>this script will run everytime someone fills in a form.what i want to do, is each time a user submits the form, is to creat the file according to their username, then add some data, this includes variblesfor example if a user wi the name test filled in the formi want to write on the file:<?$user=test$email=test.... etc... ?>how would i go about gettin this to happen? Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted August 16, 2006 Share Posted August 16, 2006 So you know how to write to files already?Well then all you should need to know is how to create them:http://uk2.php.net/touch Quote Link to comment Share on other sites More sharing options...
tomfmason Posted August 16, 2006 Share Posted August 16, 2006 our you could use the fopen like this.[code=php:0]$filename = "path/to/file/$username.whatever";$fp = fopen($filename, "x+b");$somecontent = //your posted resultsfwrite($fp, $somecontent);fclose($fp);[/code]Hope this helps,Tom Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted August 16, 2006 Share Posted August 16, 2006 Oh yeah, i forgot that fwrite would create the file if it didn't exist.I would think that is a better solution because you can write to it at the same time. 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.