JsF Posted March 12, 2008 Share Posted March 12, 2008 Does any know how it would go if I wanted to have another input box and that one creates a new folder like username? sodadome.com/username/ example ^^^^ login.php <?php //php user script //ben speakman session_start(); header("Cache-control: private"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <script type="text/javascript"> <!-- function myPopup2() { window.open( "<?php echo $_SERVER['PHP_SELF'] ?>?ls_register", "myWindow", "status = 3, height = 280, width = 289, resizable = 0" ) } //--> </script> <meta name="Description" content="Help and support my online gallery site!" /> <meta name="Keywords" content="Sodaplay, JSF, JavaScript_Freek, JavaScriptFreek, sodarace, soda, model" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="Distribution" content="Global" /> <meta name="Author" content="Dan Jasnowski - [email protected]" /> <meta name="Robots" content="index,follow" /> <link rel="stylesheet" href="images/CoolWaterContact.css" type="text/css" /> <?PHP include("phpdirects/title.php"); ?> </head> <body><a name="TemplateInfo"></a> <!-- wrap starts here --> <div id="wrap"> <!--header --> <div id="header"> <?PHP include("phpdirects/headerslogan.php"); ?> <div id="header-links"> <?PHP include("phpdirects/toprightlinks.php"); ?> </div> </div> <!-- navigation --> <?PHP include("phpdirects/headerlinks.php"); ?> <!-- content-wrap starts here --> <div id="content-wrap"> <div id="main"> <P> <?php $datafile="data.txt"; //name of the data file if($_GET['action'] == "login") { if(!isset($_POST['username']) || !isset($_POST['password'])){ //this checks that all the fields are filled in error_message("One or more required fields were left blank!", $username, $password); } $file = file($datafile); while(list(,$value) = each($file)) { list($fname,$femail,$furl,$fuser,$fpass,$blank) = explode('|', $value); if($_POST['username'] == $fuser && $_POST['password'] == $fpass){ $_SESSION['name'] = $fuser; $_SESSION['realname'] = $fname; $_SESSION['url'] = $furl; $_SESSION['email'] = $femail; //adds the users data to the php session $_SESSION['pass'] = $fpass; //insert html for sucessfull log on here //you can use . $_SESSION['name'] . for username // replace name with realname, url, email to display different name ?> <script type="text/javascript"> window.setTimeout("history.back(1)", 1000); </script> Thanks for logging in. You are now logged in.<br><BR> View you profile <a href="profile.php">here</a>.<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR> <?php $logink = true; } } if($logink !== true) { ?> Login failed, bad username/password <? } } elseif($_GET['action'] == 'change') { if(!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['url']) || !isset($_POST['newpass'])) { //this checks that all the fields are filled in ?> all fields were not filled in <? } $file = file($datafile); while(list(,$value) = each($file)){ list($fname,$femail,$furl,$fuser,$fpass) = explode('|', $value); if($_SESSION['name'] == $fuser){ //opens data file to change it $oldword = "$fname|$femail|$furl|$fuser|$fpass|"; $newword = $_POST['name'] . '|' . $_POST['email'] . '|' . $_POST['url'] . '|' . $_SESSION['name'] . '|' . $_POST['newpass'] . '|'; $fp = fopen($datafile, 'r'); $data = fread($fp, filesize($datafile)); fclose($fp); $newdata = str_replace($oldword, $newword, $data); $fp = fopen($datafile, 'w'); fwrite($fp,$newdata) or die ('error writing'); fclose($fp); $succ = true; //data changed sucessfully ?> Everything was changed successfully please <a href="user.php">login</a> <? $_SESSION['name'] = FALSE; $_SESSION['pass'] = FALSE; $_SESSION['url'] = FALSE; $_SESSION['realname'] = FALSE; $_SESSION['email'] = FALSE; } } if($succ !== true) { ?> Login failed, bad username/password <? } } else { exit; } ?> </P> <BR> </div> <div id="sidebar"> <?PHP include("phpdirects/form.php"); ?> <?PHP include("phpdirects/rightmenu.php"); ?> </div> <!-- content-wrap ends here --> </div> <!--footer starts here--> <?PHP include("phpdirects/footer.php"); ?> <!-- wrap ends here --> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/95722-on-php-registration-create-a-new-folder/ Share on other sites More sharing options...
trq Posted March 12, 2008 Share Posted March 12, 2008 mkdir(). Quote Link to comment https://forums.phpfreaks.com/topic/95722-on-php-registration-create-a-new-folder/#findComment-490201 Share on other sites More sharing options...
JsF Posted March 31, 2008 Author Share Posted March 31, 2008 I get: Warning: mkdir() [function.mkdir]: Permission denied in /home/jsfdan/public_html/dan.php on line 6 Yes the file itself dan.php is CHMOD to 0777. Also I am on a Windows XP. look for yourself: http://www.sodadome.com/dan/dan.php Quote Link to comment https://forums.phpfreaks.com/topic/95722-on-php-registration-create-a-new-folder/#findComment-505353 Share on other sites More sharing options...
wmguk Posted March 31, 2008 Share Posted March 31, 2008 can you show your code now you have the mkdir in it please? Quote Link to comment https://forums.phpfreaks.com/topic/95722-on-php-registration-create-a-new-folder/#findComment-505370 Share on other sites More sharing options...
JsF Posted March 31, 2008 Author Share Posted March 31, 2008 Sure thing. <html><title>create directory</title> <head> </head> <body> <?php mkdir("/home/jsfdan/public_html/dan2/", 0777); ?> <?php chmod("/home/jsfdan/public_html/dan/", 0777); // octal; correct value of mode ?> <?php $string = 'DAN JSF noososs.'; echo ereg_replace( 'Dan', 'JSF', $string ); ?> <br /><br /><center><br /><br /><br /> <b><font face="tahoma" color="green">testestest</font></b></center> </body></html> Quote Link to comment https://forums.phpfreaks.com/topic/95722-on-php-registration-create-a-new-folder/#findComment-505630 Share on other sites More sharing options...
JsF Posted April 1, 2008 Author Share Posted April 1, 2008 Anyone help? Quote Link to comment https://forums.phpfreaks.com/topic/95722-on-php-registration-create-a-new-folder/#findComment-506793 Share on other sites More sharing options...
wildteen88 Posted April 1, 2008 Share Posted April 1, 2008 Why are you wanting to create a new folder for each user? You're better of using just one file rather than having multiple user files. You can then use mod_rewrite so it looks as though you create a folder for every user. WIth mod_rewrote you can use have the following yoursite.com/user.php?user=username rewritten as yoursite.com/username Quote Link to comment https://forums.phpfreaks.com/topic/95722-on-php-registration-create-a-new-folder/#findComment-506797 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.