Jump to content

On PHP registration create a new folder


JsF

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/95722-on-php-registration-create-a-new-folder/
Share on other sites

  • 3 weeks later...

Sure thing.  ;D

 

<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>

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.