almightyegg Posted February 5, 2007 Share Posted February 5, 2007 when somebody signs up to my site they are given an address like www.mysite.com/username but I would like to add a file aswell as the directory (i can make the directory fine) and the file will be a redirect to the mainsite. Is there anyway to add a file to it? ??? Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/ Share on other sites More sharing options...
ted_chou12 Posted February 5, 2007 Share Posted February 5, 2007 1. what kind of file do you want to add (please give the file type extension, is it like .txt, .html, .php or/....?etc?) 2. where about do you want to place this file? TEd Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/#findComment-177601 Share on other sites More sharing options...
almightyegg Posted February 5, 2007 Author Share Posted February 5, 2007 .php and when somebody signs up they will get: mysite.com/username and i would like the file to be index.php in that directory so mysite.com/username/index.php Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/#findComment-177602 Share on other sites More sharing options...
tarun Posted February 5, 2007 Share Posted February 5, 2007 Ive Come Up With This $newfile = "username/$username.php"; $file_pointer1 = fopen("$newfile", "a"); fwrite($file_pointer1, "content"); fclose($file_pointer1); Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/#findComment-177606 Share on other sites More sharing options...
ted_chou12 Posted February 5, 2007 Share Posted February 5, 2007 <?php $file = fopen("$username/index.php","w");$write = fwrite($file,' <?php //your php page contents ?>');fclose($file); ?> one thing to notice, becareful when you are locating your index.php file, since you have just created your username folder, therefore, you have to use the same variable to locate it, noticed i used "$username". Ted Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/#findComment-177608 Share on other sites More sharing options...
tarun Posted February 5, 2007 Share Posted February 5, 2007 Also How Do You Create Directorys Beacause Thats Something Ive Wanted To Know But I Havent Got Round To It Thnx, Tarun Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/#findComment-177612 Share on other sites More sharing options...
marcus Posted February 5, 2007 Share Posted February 5, 2007 You could use mod rewrite RewriteEngine On RewriteRule ^users/([^/]*)$.php /users.php?user=$1 $1 would be ?user=USERNAME Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/#findComment-177613 Share on other sites More sharing options...
almightyegg Posted February 5, 2007 Author Share Posted February 5, 2007 some of these ideas dont make much sense to me, and the omnes that do, I've tried and they come up with errors any other ideas? Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/#findComment-177709 Share on other sites More sharing options...
Jessica Posted February 5, 2007 Share Posted February 5, 2007 mod_rewrite is really the best solution for what you want to do. Here is a great article: http://www.sitepoint.com/article/guide-url-rewriting Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/#findComment-177710 Share on other sites More sharing options...
almightyegg Posted February 6, 2007 Author Share Posted February 6, 2007 where would i find my httpd.conf file :-X I can't find it in my files. There is .htaccess and .errorlog but no httpd.conf Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/#findComment-178437 Share on other sites More sharing options...
almightyegg Posted February 6, 2007 Author Share Posted February 6, 2007 Also How Do You Create Directorys Beacause Thats Something Ive Wanted To Know But I Havent Got Round To It mkdir() Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/#findComment-178458 Share on other sites More sharing options...
Balmung-San Posted February 6, 2007 Share Posted February 6, 2007 where would i find my httpd.conf file :-X I can't find it in my files. There is .htaccess and .errorlog but no httpd.conf Assuming a Linux machine, it's usually under /etc/httpd/httpd.conf, however this differs based on the environment. As well, your web host may not allow you to edit it. I have no idea where the file resides on Windows, but I think it's in the apache directory. Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/#findComment-178460 Share on other sites More sharing options...
almightyegg Posted February 6, 2007 Author Share Posted February 6, 2007 it's not there. Maybe my host doesn't allow it then. Is there any raw code I could use instead to auto redirect www.mysite.com/username to www.mysite.com/profile.php?id=userid ??? Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/#findComment-178466 Share on other sites More sharing options...
Jessica Posted February 6, 2007 Share Posted February 6, 2007 Did you try using mod_rewrite? It might already be enabled...move on to the next step in the article, or call your host. Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/#findComment-178470 Share on other sites More sharing options...
Balmung-San Posted February 6, 2007 Share Posted February 6, 2007 Wasn't there an article on the main site recently about clean urls without mod rewrite? That involves custom error pages though, so if your host doesn't allow them (though most do), that won't work either. Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/#findComment-178474 Share on other sites More sharing options...
almightyegg Posted February 6, 2007 Author Share Posted February 6, 2007 Did you try using mod_rewrite? It might already be enabled...move on to the next step in the article, or call your host. i thought everything was done in the httpd.conf file??? Wasn't there an article on the main site recently about clean urls without mod rewrite? That involves custom error pages though, so if your host doesn't allow them (though most do), that won't work either. I have custom error pages yes, do you know where this article is? Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/#findComment-178486 Share on other sites More sharing options...
Balmung-San Posted February 6, 2007 Share Posted February 6, 2007 http://www.phpfreaks.com/tutorials/149/0.php There you go. Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/#findComment-178487 Share on other sites More sharing options...
Jessica Posted February 6, 2007 Share Posted February 6, 2007 Did you try using mod_rewrite? It might already be enabled...move on to the next step in the article, or call your host. i thought everything was done in the httpd.conf file??? No, it's done in the htaccess file. Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/#findComment-178488 Share on other sites More sharing options...
almightyegg Posted February 6, 2007 Author Share Posted February 6, 2007 how do you use the htaccess file? I tried opening it but I don't have the software... Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/#findComment-178489 Share on other sites More sharing options...
Balmung-San Posted February 6, 2007 Share Posted February 6, 2007 how do you use the htaccess file? I tried opening it but I don't have the software... .htaccess is just a plain text file. You can open it with any text editor. Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/#findComment-178490 Share on other sites More sharing options...
almightyegg Posted February 6, 2007 Author Share Posted February 6, 2007 nope...I just did that and some of it is understandable but some is all squiggles and ascii symbols Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/#findComment-178495 Share on other sites More sharing options...
Balmung-San Posted February 6, 2007 Share Posted February 6, 2007 nope...I just did that and some of it is understandable but some is all squiggles and ascii symbols That's part of how .htaccess works. For example: RewriteEngine On RewriteRule ^users/([^/]*)$.php /users.php?user=$1 from the first page would rewrite anything from the /their_username/ folder with a .php extension to users.php?user=their_username. At least I believe that's how I understood the post. Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/#findComment-178504 Share on other sites More sharing options...
almightyegg Posted February 6, 2007 Author Share Posted February 6, 2007 oh this is so god damn confusing!! would I not have to label the folder with the username varible too?? Are you sure there's no simple way to redirect www.mysite.com/username to www.mysite.com/userpage.php?id=$userid that's why I originally was going to create a file on sign up in their directory called index.php whihc would redirect but most people said I'd need mod_rewrite for that too Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/#findComment-178516 Share on other sites More sharing options...
Balmung-San Posted February 6, 2007 Share Posted February 6, 2007 Actually, that article I pointed you to would do just what you need. Just make your 404 page, then strip the URI like it says, and redirect to www.mysite.com/userpage.php?id=$stripped_uri_var. Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/#findComment-178519 Share on other sites More sharing options...
almightyegg Posted February 6, 2007 Author Share Posted February 6, 2007 but even that confused me. I will browse the net for some script or other Link to comment https://forums.phpfreaks.com/topic/37180-adding-a-php-page-on-sign-up/#findComment-178523 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.