blueman378 Posted September 17, 2007 Share Posted September 17, 2007 Hi there im currently making a site http://www.mydoodle.byethost13.com/ now what i am tryinging to do is create a php script which when you register (registration\login script already made) it will create a folder where it gets the name from the username field and password the folder with the password from the password field it will then create a page in the folder called index.php (i can make the page i just need help with the script to make the folder and page) if you need a look at my login/registration codes i will post them just request them cheers matt Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/ Share on other sites More sharing options...
LiamProductions Posted September 17, 2007 Share Posted September 17, 2007 Hmm... <?php $user = $_POST['user']; mkdir("$user", 0777); ?> To make the folder http://www.php.net Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/#findComment-350096 Share on other sites More sharing options...
blueman378 Posted September 17, 2007 Author Share Posted September 17, 2007 wow fast reply thanks is thier any thanks system on this forum? Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/#findComment-350101 Share on other sites More sharing options...
LiamProductions Posted September 17, 2007 Share Posted September 17, 2007 Nope, Donate to http://www.phpfreaks.com if you can. EDIT: The link is wrong above: Use http://www.php.net/mkdir Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/#findComment-350104 Share on other sites More sharing options...
blueman378 Posted September 18, 2007 Author Share Posted September 18, 2007 ok thanks mate thst should would well for making the folder and should using the Fopen function be used for creating the page or is there a better way? Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/#findComment-350228 Share on other sites More sharing options...
PHPNewbie55 Posted September 18, 2007 Share Posted September 18, 2007 <? fopen("$userPAGE.html", "0777"); ?> That should work... I just went through this with everyone... LOL... Good luck! Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/#findComment-350238 Share on other sites More sharing options...
blueman378 Posted September 18, 2007 Author Share Posted September 18, 2007 cheers this forum is great acctually its funny u cant post on here without getting a reply within 5 mins gotta love it thanks Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/#findComment-350243 Share on other sites More sharing options...
blueman378 Posted September 19, 2007 Author Share Posted September 19, 2007 hi well i tried doing this <? session_start(); include("database.php"); include("login.php"); /** * Returns true if the username has been taken * by another user, false otherwise. */ function usernameTaken($username){ global $conn; if(!get_magic_quotes_gpc()){ $username = addslashes($username); } $q = "select username from users where username = '$username'"; $result = mysql_query($q,$conn); return (mysql_numrows($result) > 0); } /** * Inserts the given (username, password) pair * into the database. Returns true on success, * false otherwise. */ function addNewUser($username, $password){ global $conn; $q = "INSERT INTO users VALUES ('$username', '$password')"; return mysql_query($q,$conn); } /** * Displays the appropriate message to the user * after the registration attempt. It displays a * success or failure status depending on a * session variable set during registration. */ function displayStatus(){ $uname = $_SESSION['reguname']; if($_SESSION['regresult']){ /**make the user folder*/ $user = $_POST['username']; mkdir("$user",0777); /** make the user page*/ fopen("$userindex.php",0777); ?> <h1>Registered!</h1> <p>Thank you <b><? echo $uname; ?></b>, your information has been added to the database, you may now <a href="index.php" title="Login">log in</a>.</p> <? //put the folder and file creation script here!! } else{ ?> <h1>Registration Failed</h1> <p>We're sorry, but an error has occurred and your registration for the username <b><? echo $uname; ?></b>, could not be completed.<br> Please try again at a later time.</p> <? } unset($_SESSION['reguname']); unset($_SESSION['registered']); unset($_SESSION['regresult']); } if(isset($_SESSION['registered'])){ /** * This is the page that will be displayed after the * registration has been attempted. */ ?> <HTML> <HEAD> <TITLE>My Doodle- <?php if($logged_in){ echo "Welcome $_SESSION[username]";} else{ echo "Welcome Guest";} ?> </TITLE> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- .inputarea { BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #000000 1px solid; COLOR: #000000; BORDER-BOTTOM: #000000 1px solid; FONT-FAMILY: verdana; BACKGROUND-COLOR: #A2B3F1; } .style12 { color: #222E58; font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; } body { background-image: url(images/main_bg.jpg); background-color: #93A7F0; } .titles { {font-size: 10px; font-family: Verdana, Arial; color: #000000; font-weight: bold; } .style15 { color: #FFFFFF; font-weight: bold; } .style18 { color: #333333; font-size: 18px; } --> </style> </HEAD> <BODY LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0> <!-- ImageReady Slices (business_011.psd) --> <table width="770" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td align="center" valign="top"><table width="770" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="251"><IMG SRC="images/index_01.jpg" WIDTH=251 HEIGHT=156 ALT=""></td> <td width="267" align="center" valign="top"><table width="267" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="43" align="center" valign="top" background="images/index_02.jpg"><table width="260" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="6" colspan="3"></td> </tr> <tr> <td width="30"> </td> <td align="center"><input name="textfield" type="text" size="20" class="inputarea"></td> <td><img src="images/go_img_05.jpg" width="26" height="22"></td> </tr> </table></td> </tr> <tr> <td height="8"></td> </tr> <tr> <td align="center"><img src="images/index_09.jpg" width=236 height=88 alt=""></td> </tr> </table></td> <td align="center" valign="top"><table width="252" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="3"><IMG SRC="images/index_03.jpg" WIDTH=252 HEIGHT=25 ALT=""></td> </tr> <tr> <td width="11"> </td> <td width="216" valign="top"> <?php displayLogin(); ?> </td> </tr> </table></td> <td><IMG SRC="images/index_06.jpg" WIDTH=25 HEIGHT=131 ALT=""></td> </tr> </table></td> </tr> </table> <?php $filename = 'menu.php'; if (file_exists($filename)) { include("menu.php"); } else { echo "Error the menu file $filename cannot be found please contact the administrator";} ?> <!-- PUT ALL CONTENT HERE--> <table width="100%" border="2" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#93a7f0"> <tr> <td colspan="2" align="center" background="images/index_78.jpg"><span class="style15"><font color="white"><strong>Top Uploaders</strong></font></span></td> <td rowspan="18" align="center" valign="top" background="images/main_bg_a.jpg"> <!-- Put main content in here --> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2" align="center"><img src="images/welcome.png" width="500" height="100"></td> </tr> <tr> <td> <? displayStatus(); ?> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> </table> <!-- Main end --> </td> </tr> <tr> <td width="4%"><strong>1)</strong></td> <td width="12%" align="right">Username </td> </tr> <tr> <td><strong>2)</strong></td> <td align="right">Username </td> </tr> <tr> <td><strong>3)</strong></td> <td align="right">Username </td> </tr> <tr> <td><strong>4)</strong></td> <td align="right">Username </td> </tr> <tr> <td><strong>5)</strong></td> <td align="right">Username </td> </tr> <tr> <td colspan="2" align="center" background="images/index_78.jpg"><span class="style15"><font color="white"><strong>Newest Uploads</strong></font></span></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"> </td> </tr> </table> <!-- CPNTENT END --> <table width="770" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center" valign="top" background="images/index_72.jpg"><table width="724" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="2"></td> </tr> <tr> <td height="1" bgcolor="#92A6EF"></td> </tr> <tr> </tr> <tr> <td height="1" bgcolor="#92A6EF"> <!--CONTENT BETWEEN HERE --> <table width="100%" height="100%" border="1" bordercolor="#666666"> </table> <table width="770" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="33"><IMG SRC="images/index_73.jpg" WIDTH=33 HEIGHT=30 ALT=""></td> <td width="305" background="images/index_74.jpg"><span class="style12">© My Doodle, <? print (date("Y")); ?></span></td> <td width="53"><IMG SRC="images/index_75.jpg" ALT="" WIDTH=53 HEIGHT=30 border="0"></a></td> <td width="67"><IMG SRC="images/index_76.jpg" ALT="" WIDTH=67 HEIGHT=30 border="0"></a></td> <td width="72"><IMG SRC="images/index_77.jpg" ALT="" WIDTH=72 HEIGHT=30 border="0"></a></td> <td width="80"><IMG SRC="images/index_78.jpg" ALT="" WIDTH=80 HEIGHT=30 border="0"></a></td> <td width="70"><IMG SRC="images/index_79.jpg" ALT="" WIDTH=70 HEIGHT=30 border="0"></a></td> <td width="56"><IMG SRC="images/index_80.jpg" WIDTH=56 HEIGHT=30 ALT=""></td> <td><IMG SRC="images/index_81.jpg" WIDTH=34 HEIGHT=30 ALT=""></td> </tr> </table> <table width="770" border="0" cellpadding="0" cellspacing="0" background="images/index_83.jpg"> <tr> <td width="36"><IMG SRC="images/index_82.jpg" WIDTH=36 HEIGHT=8 ALT=""></td> <td><IMG SRC="images/index_83.jpg" WIDTH=5 HEIGHT=8 ALT=""></td> <td width="34"><IMG SRC="images/index_85.jpg" WIDTH=34 HEIGHT=8 ALT=""></td> </tr> </table> <!-- End ImageReady Slices --> </BODY> </HTML> <? return; } /** * Determines whether or not to show to sign-up form * based on whether the form has been submitted, if it * has, check the database for consistency and create * the new account. */ if(isset($_POST['subjoin'])){ /* Make sure all fields were entered */ if(!$_POST['user'] || !$_POST['pass']){ die('You didn\'t fill in a required field.'); } /* Spruce up username, check length */ $_POST['user'] = trim($_POST['user']); if(strlen($_POST['user']) > 30){ die("Sorry, the username is longer than 30 characters, please shorten it."); } /* Check if username is already in use */ if(usernameTaken($_POST['user'])){ $use = $_POST['user']; die("Sorry, the username: <strong>$use</strong> is already taken, please pick another one."); } /* Add the new account to the database */ $md5pass = md5($_POST['pass']); $_SESSION['reguname'] = $_POST['user']; $_SESSION['regresult'] = addNewUser($_POST['user'], $md5pass); $_SESSION['registered'] = true; echo "<meta http-equiv=\"Refresh\" content=\"0;url=$HTTP_SERVER_VARS[php_SELF]\">"; return; } else{ /** * This is the page with the sign-up form, the names * of the input fields are important and should not * be changed. */ ?> <HTML> <HEAD> <TITLE>My Doodle- <?php if($logged_in){ echo "Welcome $_SESSION[username]";} else{ echo "Welcome Guest";} ?> </TITLE> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- .inputarea { BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #000000 1px solid; COLOR: #000000; BORDER-BOTTOM: #000000 1px solid; FONT-FAMILY: verdana; BACKGROUND-COLOR: #A2B3F1; } .style12 { color: #222E58; font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; } body { background-image: url(images/main_bg.jpg); background-color: #93A7F0; } .titles { {font-size: 10px; font-family: Verdana, Arial; color: #000000; font-weight: bold; } .style15 { color: #FFFFFF; font-weight: bold; } .style18 { color: #333333; font-size: 18px; } --> </style> </HEAD> <BODY LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0> <!-- ImageReady Slices (business_011.psd) --> <table width="770" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td align="center" valign="top"><table width="770" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="251"><IMG SRC="images/index_01.jpg" WIDTH=251 HEIGHT=156 ALT=""></td> <td width="267" align="center" valign="top"><table width="267" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="43" align="center" valign="top" background="images/index_02.jpg"><table width="260" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="6" colspan="3"></td> </tr> <tr> <td width="30"> </td> <td align="center"><input name="textfield" type="text" size="20" class="inputarea"></td> <td><img src="images/go_img_05.jpg" width="26" height="22"></td> </tr> </table></td> </tr> <tr> <td height="8"></td> </tr> <tr> <td align="center"><img src="images/index_09.jpg" width=236 height=88 alt=""></td> </tr> </table></td> <td align="center" valign="top"><table width="252" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="3"><IMG SRC="images/index_03.jpg" WIDTH=252 HEIGHT=25 ALT=""></td> </tr> <tr> <td width="11"> </td> <td width="216" valign="top"> <?php displayLogin(); ?> </td> </tr> </table></td> <td><IMG SRC="images/index_06.jpg" WIDTH=25 HEIGHT=131 ALT=""></td> </tr> </table></td> </tr> </table> <?php $filename = 'menu.php'; if (file_exists($filename)) { include("menu.php"); } else { echo "Error the menu file $filename cannot be found please contact the administrator";} ?> <!-- PUT ALL CONTENT HERE--> <table width="100%" border="2" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#93a7f0"> <tr> <td colspan="2" align="center" background="images/index_78.jpg"><span class="style15"><font color="white"><strong>Top Uploaders</strong></font></span></td> <td rowspan="18" align="center" valign="top" background="images/main_bg_a.jpg"> <!-- Put main content in here --> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2" align="center"><img src="images/welcome.png" width="500" height="100"></td> </tr> <tr> <td> <h1>Welcome and thank you for registering at My Doodle</h1> <h3>Register</h3> <form action="<? echo $HTTP_SERVER_VARS['PHP_SELF']; ?>" method="post"> <table align="left" border="0" cellspacing="0" cellpadding="3"> <tr><td>Username:</td><td><input type="text" name="user" maxlength="30"></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" maxlength="30"></td></tr> <tr><td colspan="2" align="right"><input type="submit" name="subjoin" value="Join!"></td></tr> </table> </form></td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> </table> <!-- Main end --> </td> </tr> <tr> <td width="4%"><strong>1)</strong></td> <td width="12%" align="right">Username </td> </tr> <tr> <td><strong>2)</strong></td> <td align="right">Username </td> </tr> <tr> <td><strong>3)</strong></td> <td align="right">Username </td> </tr> <tr> <td><strong>4)</strong></td> <td align="right">Username </td> </tr> <tr> <td><strong>5)</strong></td> <td align="right">Username </td> </tr> <tr> <td colspan="2" align="center" background="images/index_78.jpg"><span class="style15"><font color="white"><strong>Newest Uploads</strong></font></span></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"> </td> </tr> </table> <!-- CPNTENT END --> <table width="770" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center" valign="top" background="images/index_72.jpg"><table width="724" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="2"></td> </tr> <tr> <td height="1" bgcolor="#92A6EF"></td> </tr> <tr> </tr> <tr> <td height="1" bgcolor="#92A6EF"> <!--CONTENT BETWEEN HERE --> <table width="100%" height="100%" border="1" bordercolor="#666666"> </table> <table width="770" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="33"><IMG SRC="images/index_73.jpg" WIDTH=33 HEIGHT=30 ALT=""></td> <td width="305" background="images/index_74.jpg"><span class="style12">© My Doodle, <? print (date("Y")); ?></span></td> <td width="53"><IMG SRC="images/index_75.jpg" ALT="" WIDTH=53 HEIGHT=30 border="0"></a></td> <td width="67"><IMG SRC="images/index_76.jpg" ALT="" WIDTH=67 HEIGHT=30 border="0"></a></td> <td width="72"><IMG SRC="images/index_77.jpg" ALT="" WIDTH=72 HEIGHT=30 border="0"></a></td> <td width="80"><IMG SRC="images/index_78.jpg" ALT="" WIDTH=80 HEIGHT=30 border="0"></a></td> <td width="70"><IMG SRC="images/index_79.jpg" ALT="" WIDTH=70 HEIGHT=30 border="0"></a></td> <td width="56"><IMG SRC="images/index_80.jpg" WIDTH=56 HEIGHT=30 ALT=""></td> <td><IMG SRC="images/index_81.jpg" WIDTH=34 HEIGHT=30 ALT=""></td> </tr> </table> <table width="770" border="0" cellpadding="0" cellspacing="0" background="images/index_83.jpg"> <tr> <td width="36"><IMG SRC="images/index_82.jpg" WIDTH=36 HEIGHT=8 ALT=""></td> <td><IMG SRC="images/index_83.jpg" WIDTH=5 HEIGHT=8 ALT=""></td> <td width="34"><IMG SRC="images/index_85.jpg" WIDTH=34 HEIGHT=8 ALT=""></td> </tr> </table> <!-- End ImageReady Slices --> </BODY> </HTML> <? } ?> and i get these errors Warning: mkdir() [function.mkdir]: File exists in C:\Documents and Settings\User\My Documents\PHP\HTDOCS\register.php on line 42 Warning: fopen(.php) [function.fopen]: failed to open stream: File exists in C:\Documents and Settings\User\My Documents\PHP\HTDOCS\register.php on line 45 Registered! Thank you testuser3, your information has been added to the database, you may now log in. any help would be appreciated thanks Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/#findComment-350874 Share on other sites More sharing options...
remlabm Posted September 19, 2007 Share Posted September 19, 2007 mkdir() = your not passing the directory to make example if i wanted to make a dir called test it would look something like mkdir("/home/public_html/test"); same with your fopen... its fopen(.php)... you need to put the absolute path... $handle = fopen("/home/public_html/test/whatever.php","0755"); you will also need to CHMOD the new directory you made chmod("home/public_html/test", "0777"); to figure out absolute paths you can look at your phpinfo file. Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/#findComment-350876 Share on other sites More sharing options...
blueman378 Posted September 19, 2007 Author Share Posted September 19, 2007 ok thanks so how would i make a folder that uses a variable eg users\$user Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/#findComment-350915 Share on other sites More sharing options...
blueman378 Posted September 19, 2007 Author Share Posted September 19, 2007 ok im getting close i think now the part i am getting errors with is this fopen("/home/vol2/byethost13.com/b13_1013561/mydoodle.byethost13.com/htdocs/users/".$user"\\index.php","0777"); echo "file created"; ?> thats lines 46/47 the error is faultCode0faultStringParse error:syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/vol2/byethost13.com/b13_1013561/mydoodle.byethost13.com/htdocs/register.php on line 46 thanks for any help Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/#findComment-350921 Share on other sites More sharing options...
JJohnsenDK Posted September 19, 2007 Share Posted September 19, 2007 which line is 46? Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/#findComment-350927 Share on other sites More sharing options...
blueman378 Posted September 19, 2007 Author Share Posted September 19, 2007 top fopen("/home/vol2/byethost13.com/b13_1013561/mydoodle.byethost13.com/htdocs/users/".$user"\\index.php","0777"); Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/#findComment-350928 Share on other sites More sharing options...
JJohnsenDK Posted September 19, 2007 Share Posted September 19, 2007 i think you are missing a . in the fopen and have turned the backslash wrong, try this: <?php fopen("/home/vol2/byethost13.com/b13_1013561/mydoodle.byethost13.com/htdocs/users/".$user."/index.php","0777"); echo "file created"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/#findComment-350931 Share on other sites More sharing options...
blueman378 Posted September 19, 2007 Author Share Posted September 19, 2007 is thier any way to make my links relative to where register.php is? Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/#findComment-350936 Share on other sites More sharing options...
JJohnsenDK Posted September 19, 2007 Share Posted September 19, 2007 did what i wrote help? I dont understand your quesstion? Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/#findComment-350940 Share on other sites More sharing options...
blueman378 Posted September 19, 2007 Author Share Posted September 19, 2007 yeah it did, it stopped that error i will post all relative information DOC ROOT: /home/vol2/byethost13.com/b13_1013561/mydoodle.byethost13.com/htdocs register.php <? session_start(); include("database.php"); include("login.php"); /** * Returns true if the username has been taken * by another user, false otherwise. */ function usernameTaken($username){ global $conn; if(!get_magic_quotes_gpc()){ $username = addslashes($username); } $q = "select username from users where username = '$username'"; $result = mysql_query($q,$conn); return (mysql_numrows($result) > 0); } /** * Inserts the given (username, password) pair * into the database. Returns true on success, * false otherwise. */ function addNewUser($username, $password){ global $conn; $q = "INSERT INTO users VALUES ('$username', '$password')"; return mysql_query($q,$conn); } /** * Displays the appropriate message to the user * after the registration attempt. It displays a * success or failure status depending on a * session variable set during registration. */ function displayStatus(){ $uname = $_SESSION['reguname']; if($_SESSION['regresult']){ /**make the user folder*/ mkdir ("/home/vol2/byethost13.com/b13_1013561/mydoodle.byethost13.com/htdocs/users/".$uname,"0777"); echo "Folder $uname created"; /** make the user page*/ fopen ("/home/vol2/byethost13.com/b13_1013561/mydoodle.byethost13.com/htdocs/users/".$uname."index.php","0777"); echo "file created"; ?> <h1>Registered!</h1> <p>Thank you <b><? echo $uname; ?></b>, your information has been added to the database, you may now <a href="index.php" title="Login">log in</a>.</p> <? } else{ ?> <h1>Registration Failed</h1> <p>We're sorry, but an error has occurred and your registration for the username <b><? echo $uname; ?></b>, could not be completed.<br> Please try again at a later time.</p> <? } unset($_SESSION['reguname']); unset($_SESSION['registered']); unset($_SESSION['regresult']); } if(isset($_SESSION['registered'])){ /** * This is the page that will be displayed after the * registration has been attempted. */ ?> <HTML> <HEAD> <TITLE>My Doodle- <?php if($logged_in){ echo "Welcome $_SESSION[username]";} else{ echo "Welcome Guest";} ?> </TITLE> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- .inputarea { BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #000000 1px solid; COLOR: #000000; BORDER-BOTTOM: #000000 1px solid; FONT-FAMILY: verdana; BACKGROUND-COLOR: #A2B3F1; } .style12 { color: #222E58; font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; } body { background-image: url(images/main_bg.jpg); background-color: #93A7F0; } .titles { {font-size: 10px; font-family: Verdana, Arial; color: #000000; font-weight: bold; } .style15 { color: #FFFFFF; font-weight: bold; } .style18 { color: #333333; font-size: 18px; } --> </style> </HEAD> <BODY LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0> <!-- ImageReady Slices (business_011.psd) --> <table width="770" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td align="center" valign="top"><table width="770" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="251"><IMG SRC="images/index_01.jpg" WIDTH=251 HEIGHT=156 ALT=""></td> <td width="267" align="center" valign="top"><table width="267" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="43" align="center" valign="top" background="images/index_02.jpg"><table width="260" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="6" colspan="3"></td> </tr> <tr> <td width="30"> </td> <td align="center"><input name="textfield" type="text" size="20" class="inputarea"></td> <td><img src="images/go_img_05.jpg" width="26" height="22"></td> </tr> </table></td> </tr> <tr> <td height="8"></td> </tr> <tr> <td align="center"><img src="images/index_09.jpg" width=236 height=88 alt=""></td> </tr> </table></td> <td align="center" valign="top"><table width="252" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="3"><IMG SRC="images/index_03.jpg" WIDTH=252 HEIGHT=25 ALT=""></td> </tr> <tr> <td width="11"> </td> <td width="216" valign="top"> <?php displayLogin(); ?> </td> </tr> </table></td> <td><IMG SRC="images/index_06.jpg" WIDTH=25 HEIGHT=131 ALT=""></td> </tr> </table></td> </tr> </table> <?php $filename = 'menu.php'; if (file_exists($filename)) { include("menu.php"); } else { echo "Error the menu file $filename cannot be found please contact the administrator";} ?> <!-- PUT ALL CONTENT HERE--> <table width="100%" border="2" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#93a7f0"> <tr> <td colspan="2" align="center" background="images/index_78.jpg"><span class="style15"><font color="white"><strong>Top Uploaders</strong></font></span></td> <td rowspan="18" align="center" valign="top" background="images/main_bg_a.jpg"> <!-- Put main content in here --> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2" align="center"><img src="images/welcome.png" width="500" height="100"></td> </tr> <tr> <td> <? displayStatus(); ?> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> </table> <!-- Main end --> </td> </tr> <tr> <td width="4%"><strong>1)</strong></td> <td width="12%" align="right">Username </td> </tr> <tr> <td><strong>2)</strong></td> <td align="right">Username </td> </tr> <tr> <td><strong>3)</strong></td> <td align="right">Username </td> </tr> <tr> <td><strong>4)</strong></td> <td align="right">Username </td> </tr> <tr> <td><strong>5)</strong></td> <td align="right">Username </td> </tr> <tr> <td colspan="2" align="center" background="images/index_78.jpg"><span class="style15"><font color="white"><strong>Newest Uploads</strong></font></span></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"> </td> </tr> </table> <!-- CPNTENT END --> <table width="770" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center" valign="top" background="images/index_72.jpg"><table width="724" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="2"></td> </tr> <tr> <td height="1" bgcolor="#92A6EF"></td> </tr> <tr> </tr> <tr> <td height="1" bgcolor="#92A6EF"> <!--CONTENT BETWEEN HERE --> <table width="100%" height="100%" border="1" bordercolor="#666666"> </table> <table width="770" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="33"><IMG SRC="images/index_73.jpg" WIDTH=33 HEIGHT=30 ALT=""></td> <td width="305" background="images/index_74.jpg"><span class="style12">© My Doodle, <? print (date("Y")); ?></span></td> <td width="53"><IMG SRC="images/index_75.jpg" ALT="" WIDTH=53 HEIGHT=30 border="0"></a></td> <td width="67"><IMG SRC="images/index_76.jpg" ALT="" WIDTH=67 HEIGHT=30 border="0"></a></td> <td width="72"><IMG SRC="images/index_77.jpg" ALT="" WIDTH=72 HEIGHT=30 border="0"></a></td> <td width="80"><IMG SRC="images/index_78.jpg" ALT="" WIDTH=80 HEIGHT=30 border="0"></a></td> <td width="70"><IMG SRC="images/index_79.jpg" ALT="" WIDTH=70 HEIGHT=30 border="0"></a></td> <td width="56"><IMG SRC="images/index_80.jpg" WIDTH=56 HEIGHT=30 ALT=""></td> <td><IMG SRC="images/index_81.jpg" WIDTH=34 HEIGHT=30 ALT=""></td> </tr> </table> <table width="770" border="0" cellpadding="0" cellspacing="0" background="images/index_83.jpg"> <tr> <td width="36"><IMG SRC="images/index_82.jpg" WIDTH=36 HEIGHT=8 ALT=""></td> <td><IMG SRC="images/index_83.jpg" WIDTH=5 HEIGHT=8 ALT=""></td> <td width="34"><IMG SRC="images/index_85.jpg" WIDTH=34 HEIGHT=8 ALT=""></td> </tr> </table> <!-- End ImageReady Slices --> </BODY> </HTML> <? return; } /** * Determines whether or not to show to sign-up form * based on whether the form has been submitted, if it * has, check the database for consistency and create * the new account. */ if(isset($_POST['subjoin'])){ /* Make sure all fields were entered */ if(!$_POST['user'] || !$_POST['pass']){ die('You didn\'t fill in a required field.'); } /* Spruce up username, check length */ $_POST['user'] = trim($_POST['user']); if(strlen($_POST['user']) > 30){ die("Sorry, the username is longer than 30 characters, please shorten it."); } /* Check if username is already in use */ if(usernameTaken($_POST['user'])){ $use = $_POST['user']; die("Sorry, the username: <strong>$use</strong> is already taken, please pick another one."); } /* Add the new account to the database */ $md5pass = md5($_POST['pass']); $_SESSION['reguname'] = $_POST['user']; $_SESSION['regresult'] = addNewUser($_POST['user'], $md5pass); $_SESSION['registered'] = true; echo "<meta http-equiv=\"Refresh\" content=\"0;url=$HTTP_SERVER_VARS[php_SELF]\">"; return; } else{ /** * This is the page with the sign-up form, the names * of the input fields are important and should not * be changed. */ ?> <HTML> <HEAD> <TITLE>My Doodle- <?php if($logged_in){ echo "Welcome $_SESSION[username]";} else{ echo "Welcome Guest";} ?> </TITLE> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- .inputarea { BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #000000 1px solid; COLOR: #000000; BORDER-BOTTOM: #000000 1px solid; FONT-FAMILY: verdana; BACKGROUND-COLOR: #A2B3F1; } .style12 { color: #222E58; font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; } body { background-image: url(images/main_bg.jpg); background-color: #93A7F0; } .titles { {font-size: 10px; font-family: Verdana, Arial; color: #000000; font-weight: bold; } .style15 { color: #FFFFFF; font-weight: bold; } .style18 { color: #333333; font-size: 18px; } --> </style> </HEAD> <BODY LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0> <!-- ImageReady Slices (business_011.psd) --> <table width="770" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td align="center" valign="top"><table width="770" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="251"><IMG SRC="images/index_01.jpg" WIDTH=251 HEIGHT=156 ALT=""></td> <td width="267" align="center" valign="top"><table width="267" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="43" align="center" valign="top" background="images/index_02.jpg"><table width="260" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="6" colspan="3"></td> </tr> <tr> <td width="30"> </td> <td align="center"><input name="textfield" type="text" size="20" class="inputarea"></td> <td><img src="images/go_img_05.jpg" width="26" height="22"></td> </tr> </table></td> </tr> <tr> <td height="8"></td> </tr> <tr> <td align="center"><img src="images/index_09.jpg" width=236 height=88 alt=""></td> </tr> </table></td> <td align="center" valign="top"><table width="252" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="3"><IMG SRC="images/index_03.jpg" WIDTH=252 HEIGHT=25 ALT=""></td> </tr> <tr> <td width="11"> </td> <td width="216" valign="top"> <?php displayLogin(); ?> </td> </tr> </table></td> <td><IMG SRC="images/index_06.jpg" WIDTH=25 HEIGHT=131 ALT=""></td> </tr> </table></td> </tr> </table> <?php $filename = 'menu.php'; if (file_exists($filename)) { include("menu.php"); } else { echo "Error the menu file $filename cannot be found please contact the administrator";} ?> <!-- PUT ALL CONTENT HERE--> <table width="100%" border="2" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#93a7f0"> <tr> <td colspan="2" align="center" background="images/index_78.jpg"><span class="style15"><font color="white"><strong>Top Uploaders</strong></font></span></td> <td rowspan="18" align="center" valign="top" background="images/main_bg_a.jpg"> <!-- Put main content in here --> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2" align="center"><img src="images/welcome.png" width="500" height="100"></td> </tr> <tr> <td> <h1>Welcome and thank you for registering at My Doodle</h1> <h3>Register</h3> <form action="<? echo $HTTP_SERVER_VARS['PHP_SELF']; ?>" method="post"> <table align="left" border="0" cellspacing="0" cellpadding="3"> <tr><td>Username:</td><td><input type="text" name="user" maxlength="30"></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" maxlength="30"></td></tr> <tr><td colspan="2" align="right"><input type="submit" name="subjoin" value="Join!"></td></tr> </table> </form></td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> </table> <!-- Main end --> </td> </tr> <tr> <td width="4%"><strong>1)</strong></td> <td width="12%" align="right">Username </td> </tr> <tr> <td><strong>2)</strong></td> <td align="right">Username </td> </tr> <tr> <td><strong>3)</strong></td> <td align="right">Username </td> </tr> <tr> <td><strong>4)</strong></td> <td align="right">Username </td> </tr> <tr> <td><strong>5)</strong></td> <td align="right">Username </td> </tr> <tr> <td colspan="2" align="center" background="images/index_78.jpg"><span class="style15"><font color="white"><strong>Newest Uploads</strong></font></span></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"><strong>Name</strong> by <em>User</em></td> </tr> <tr> <td colspan="2"> </td> </tr> </table> <!-- CPNTENT END --> <table width="770" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center" valign="top" background="images/index_72.jpg"><table width="724" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="2"></td> </tr> <tr> <td height="1" bgcolor="#92A6EF"></td> </tr> <tr> </tr> <tr> <td height="1" bgcolor="#92A6EF"> <!--CONTENT BETWEEN HERE --> <table width="100%" height="100%" border="1" bordercolor="#666666"> </table> <table width="770" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="33"><IMG SRC="images/index_73.jpg" WIDTH=33 HEIGHT=30 ALT=""></td> <td width="305" background="images/index_74.jpg"><span class="style12">© My Doodle, <? print (date("Y")); ?></span></td> <td width="53"><IMG SRC="images/index_75.jpg" ALT="" WIDTH=53 HEIGHT=30 border="0"></a></td> <td width="67"><IMG SRC="images/index_76.jpg" ALT="" WIDTH=67 HEIGHT=30 border="0"></a></td> <td width="72"><IMG SRC="images/index_77.jpg" ALT="" WIDTH=72 HEIGHT=30 border="0"></a></td> <td width="80"><IMG SRC="images/index_78.jpg" ALT="" WIDTH=80 HEIGHT=30 border="0"></a></td> <td width="70"><IMG SRC="images/index_79.jpg" ALT="" WIDTH=70 HEIGHT=30 border="0"></a></td> <td width="56"><IMG SRC="images/index_80.jpg" WIDTH=56 HEIGHT=30 ALT=""></td> <td><IMG SRC="images/index_81.jpg" WIDTH=34 HEIGHT=30 ALT=""></td> </tr> </table> <table width="770" border="0" cellpadding="0" cellspacing="0" background="images/index_83.jpg"> <tr> <td width="36"><IMG SRC="images/index_82.jpg" WIDTH=36 HEIGHT=8 ALT=""></td> <td><IMG SRC="images/index_83.jpg" WIDTH=5 HEIGHT=8 ALT=""></td> <td width="34"><IMG SRC="images/index_85.jpg" WIDTH=34 HEIGHT=8 ALT=""></td> </tr> </table> <!-- End ImageReady Slices --> </BODY> </HTML> <? } ?> ERROR I AM GETTING FROM THIS CODE: faultCode0faultStringWarning:mkdir() [function.mkdir]: File exists in /home/vol2/byethost13.com/b13_1013561/mydoodle.byethost13.com/htdocs/register.php on line 42Folder createdfaultCode0faultStringWarning:fopen(/home/vol2/byethost13.com/b13_1013561/mydoodle.byethost13.com/htdocs/users/index.php) [function.fopen]: failed to open stream: No such file or directory in /home/vol2/byethost13.com/b13_1013561/mydoodle.byethost13.com/htdocs/register.php on line 46file created Registered! Thank you TESTER, your information has been added to the database, you may now log in. basically i want this to work lol thanks Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/#findComment-350942 Share on other sites More sharing options...
blueman378 Posted September 19, 2007 Author Share Posted September 19, 2007 you can test it at mydoodle.byethost13.com thanks for all your help everyone Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/#findComment-350943 Share on other sites More sharing options...
blueman378 Posted September 19, 2007 Author Share Posted September 19, 2007 well im slowly getting there i now have the folder creation working but when the file create runs i get error: Folder test3 created/n/nfaultCode0faultStringWarning:fopen(/home/vol2/byethost13.com/b13_1013561/mydoodle.byethost13.com/htdocs/users/test3/index.php) [function.fopen]: failed to open stream: Permission denied in /home/vol2/byethost13.com/b13_1013561/mydoodle.byethost13.com/htdocs/register.php on line 45file created the username was test3 my new code is: /**make the user folder*/ mkdir ("/home/vol2/byethost13.com/b13_1013561/mydoodle.byethost13.com/htdocs/users/".$uname,"0777"); echo "Folder $uname created/n/n"; /** make the user page*/ fopen ("/home/vol2/byethost13.com/b13_1013561/mydoodle.byethost13.com/htdocs/users/".$uname."/index.php","0777"); echo "file created"; any help appreciated Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/#findComment-350951 Share on other sites More sharing options...
JJohnsenDK Posted September 19, 2007 Share Posted September 19, 2007 the error means that you doesnt have permission to create folders in the folder you want to create the folder in. So log on to your webhost server and change the permission. That should help on that error Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/#findComment-350982 Share on other sites More sharing options...
blueman378 Posted September 19, 2007 Author Share Posted September 19, 2007 thanks mate that worked well acctually now heres my code /**make the user folder*/ mkdir ("/home/vol2/byethost13.com/b13_1013561/mydoodle.byethost13.com/htdocs/users/".$uname, 0777); echo "Folder $uname created \n"; /** make the user page*/ fopen ("/home/vol2/byethost13.com/b13_1013561/mydoodle.byethost13.com/htdocs/users/".$uname."/index.php", 'w', 0777); echo "file created \n"; which works perfectly but now using the fopen command how would i write html data into the file create? cheers Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/#findComment-350986 Share on other sites More sharing options...
JJohnsenDK Posted September 19, 2007 Share Posted September 19, 2007 For that you use the fwrite() function read more here: http://dk.php.net/manual/da/function.fwrite.php Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/#findComment-350989 Share on other sites More sharing options...
blueman378 Posted September 19, 2007 Author Share Posted September 19, 2007 thanks this site is amazing this was my first real script i have wrote and it owuld have been impossible withouy the help of phpfreaks thankyou Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/#findComment-350990 Share on other sites More sharing options...
JJohnsenDK Posted September 19, 2007 Share Posted September 19, 2007 np... we all have to start somewhere Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/#findComment-350993 Share on other sites More sharing options...
blueman378 Posted September 19, 2007 Author Share Posted September 19, 2007 how would you rate the difficulty of what i am doing for a very first attempt? Quote Link to comment https://forums.phpfreaks.com/topic/69677-solved-creating-a-folder-and-page-with-php/#findComment-350994 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.