PHP Website Creator...Almost done!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bumple
Forum Commoner
Posts: 34
Joined: Thu Jan 08, 2004 4:38 am

PHP Website Creator...Almost done!

Post by bumple »

Ignore.
Last edited by bumple on Fri Feb 20, 2004 9:36 am, edited 1 time in total.
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

well, if it were http://www.<span style='color:red;text-decoration:blink' title='Alert a moderator!'>grilled spam</span>.com/index.php?username=bla then that would've saved you some time, you could've used theusername to find out the settingsinthe database and use 1 file to load it up...thats it, but with your setup you will need a script to make the /username/ dir.

look at [php_man]mkdir[/php_man] and [php_man]chmod[/php_man].

after you get the dir you need to make the file in that dir, look at

[php_man]fopen[/php_man] and [php_man]fwrite[/php_man]...

if you know how to do these and i am talking about something else for some weird reasn then please expline more, i dont really understand what you want php to do..
bumple
Forum Commoner
Posts: 34
Joined: Thu Jan 08, 2004 4:38 am

Post by bumple »

well, the problem is, I want it to be easy to access...maybe not <span style='color:red;text-decoration:blink' title='Alert a moderator!'>grilled spam</span>.com/username/index.php....but users.<span style='color:red;text-decoration:blink' title='Alert a moderator!'>grilled spam</span>.com/username

Is there anyway I can do it like xanga...when you type in http://www.xanga.com/idiot ... it redirects you to http://www.xanga.com/home.aspx?user=idiot

is there any way to do that?
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

you could have a directory as the username and then in that directory an index.php file that contains something like:

Code: Select all

<?php
header("Location: http://<span style='color:red;text-decoration:blink' title='Alert a moderator!'>grilled spam</span>.com/index.php?user=idiot");
?>
Im %99.9 sure that will work!
bumple
Forum Commoner
Posts: 34
Joined: Thu Jan 08, 2004 4:38 am

Post by bumple »

The problem I must first overcome is creating that directory and index.php for the unique users...How would I do that?

First I would do something like: "mkdir $_SESSION['username']" (what should the chmod be here? I ONLY WANT THEM TO BE ABLE TO READ IT).

Then I would have to create an index.php in their folder...how would I do that?
mahara
Forum Commoner
Posts: 37
Joined: Wed Nov 13, 2002 1:08 am
Location: Bandung, Jawa Barat, Indonesia

Post by mahara »

Well, I don't get the reason why you should do that way. It can be too risk, eg when you talk about security problem, you should implement who deserve accessing the directory. There's other things you should consider, including the complexity of implementing the code.
bumple
Forum Commoner
Posts: 34
Joined: Thu Jan 08, 2004 4:38 am

Post by bumple »

alright...so how would i make my site work like xanga?

Is there anyway I can do it like xanga...when you type in http://www.xanga.com/idiot ... it redirects you to http://www.xanga.com/home.aspx?user=idiot

All it would do is fetch the information for somebody with the username "idiot"...it shouldn't be too complex.
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

bumple wrote: All it would do is fetch the information for somebody with the username "idiot"...it shouldn't be too complex.
I don't want to be too harsh, but if it doesn't sound too complex, why are you asking? The reason I'm bothering is because it sounds more like you are asking someone to write this for you without coming out and saying as much.

Which a lot of us feel is a big no no around here.

A couple of others gave you some good ideas and some mentioned some functions to use. All of them valid to one extent or another. Now it's up to you to take those ideas, put your thinking cap on and try to build something.

So go to the manual and check out the mkdir function for example. You'll also see that there are a good number of examples there on how to use it.

Go to google and search for examples on how to redirect pages. Google isn't too complex you know. :wink:

You can do it, but you're at that point where you need to start thinking for yourself.

Cheers,
BDKR
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

BDKR is right, i checked out this post few times to see if you made any prograss, my post gives you all the functions you need, along with the idea about what to do, even if you dont agree with my idea then there still options for you.

how to make user based dir upon regeisterion..

user submits form
validate it
make dir with [php_man]mkdir[/php_man] with $username as dir name...
use [php_man]chmod[/php_man] (0777), and write index.php useing [php_man]fopen[/php_man], [php_man]fwrite[/php_man] and [php_man]fclose[/php_man]
use chmod on the dir u just created and on index.php too (0755)
after confirming that the dir and index.php were made without any errors, do rest of your things like inserting user info in db.

if you need help with writeing files then check out [google]file manipulation with php[/google] @ google..

good luck.
Straterra
Forum Regular
Posts: 527
Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:

Post by Straterra »

Also, if he says he doesn't want a bla.php?user=bigtoe , can't he just use modrewrite?
bumple
Forum Commoner
Posts: 34
Joined: Thu Jan 08, 2004 4:38 am

Post by bumple »

Ignore.
Gremlin
Forum Newbie
Posts: 13
Joined: Thu May 02, 2002 7:03 pm
Location: California
Contact:

Post by Gremlin »

mod rewrite can turn http://www.foo.com?section=news&article=somenews&page=3 into

http://www.foo.com/news/somenews/3/
(or http://www.something.com?user=me into http://www.something.com/me, where the '/' isn't a directory reference but a placeeholder for the ?var=value pairs in the url, then have a script in the index page's code to check to see if $user is set, exists in the db, other security stuff then redirect to another page)

you simply need a logical and fairly constant variable set coming in via the url and a little bit of regexp experience.
Gremlin
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Bumple don't edit your posts and say ignore... maybe someone is having the same problem and wants to read up on it....
bumple
Forum Commoner
Posts: 34
Joined: Thu Jan 08, 2004 4:38 am

Post by bumple »

true dat foo
User avatar
Derfel Cadarn
Forum Contributor
Posts: 193
Joined: Thu Jul 17, 2003 12:02 pm
Location: Berlin, Germany

Post by Derfel Cadarn »

Phenom wrote:Bumple don't edit your posts and say ignore... maybe someone is having the same problem and wants to read up on it....
True: Bumple sucks! :twisted: :evil: :twisted:
This forumis to learn from mistakes or questions, not to irritate others!
:x :x
Post Reply