Hi all!

I still consider myself to be a newbie at PHP, but i have managed to develop a good PHP application, thanks in a large part to daniweb members' help and advice.

My problem now is, having coded a profile page (profile.php) which displays user information dependent on the username/password variables passed to it, i am now attempting to automatically create a "duplicate" file named "/$username" with all the information from the users profile.php file, which can then be accessed via a personal URL.

For example, in my case, if i login as "ben" i am then directed to http://mywebsite.com/profile.php where i can add, modify my profile information via PHP, Javascript and Mysql. Now having added or modified any information, if i navigate to http://mywebsite.com/ben i would like this file to show the up to date infomation.

I hope i'm explaining this ok, any help on this including things i may have to research further would be invaluable to me.

Many thanks in advance.

I take it that you want to dynamically create the personal pages. Even if you want the page to have a personalized name, the content can be standard. Then all you have to do is have the standard version and copy it to the new personalized name (php copy command). It can be passed a parameter for the name or extract it from the url.

Thanks for the reply. This seems to work very well and is very simple. But obviously now anyone can navigate to http;//mywebsite.com/ben.php and change ben's profile. Is there a way to copy a php file, disable the php and somehow convert it to an html file?

I have tried doing this by simply:

copy("source.php","new_file.html");

But then obviously this displays all the php as html strings rather than the users actual information.

Please help?!

look at the documentation for .htaccess mod_rewrite for your apache server
it is easy in .htaccess to change the displayed url of /mysite.com/profile.php?user=XXX to /mysite/profiles/XXX.html (or anything else)
everyony can see /profiles/ben.html
but session/login set that only someone properly logging in as Ben can modify /profiles/ben.html
there is no requirement for any personalised pages to actually exist, my site has 1600 pages in google,
=> 15scripts 2db and 307folders full of vid + images (BLOB take too long) make those pages, (several thousand pages that arent different enough to get indexed)
-none of the pages exist

all database, queries create the page on the fly in a php template, output to the browser as .html,
updates to allow the user to make LIMITED modification to their own details
there is definitely no requrement to copy anything on the server, not the approach used anywhere

your profile page here on DaniWeb likely does not exist either, its likely to be profile.php pulling your details from the database

perhaps a bit long for the reply, but its a shitload easier to build it right, when you design the site, than to fix it later when there are (hopefully, good luck anyway) thousands of users overloading your server

likely all this stuff can be found in one of the script repositories; hotscripts phpscripts cnet.download justscripts,
already made under general headings :: user-control, access control, subscription control, membership

edit this is the google search I used, there are thousands

this one is included as humour, not to dag on a person who identifies themself as new, & has made effort & asked the right questions, If I were dagging on you, it would have been the only response on the answer.

bet everyone clicks the second link

Thanks for the advice Alomostbob!

Can i just clarify some things though; i'll use DaniWeb as an example. When i navigate to my profile page - daniweb/profile.php?etcetera - i can modify my personal information. This is very similar to my website's profile.php file.

What i'm trying to do now is create a 'profile page' which can be visible to anyone who navigates to it. In a similar way to DaniWeb - if i navigate to my 'profile page', which looks something like daniweb.com/forum/member146537.html it displays everything which i have updated in the daniweb/profile.php?etcetera. But in an html format. Some of the information in the /member1465737.html for example 'total up-votes' and 'total down-votes' recieved must be supplied via php and the database - right? - and yet it's an html file (or is it?!) - are they using .htaccess mod_rewrite to change /profile.php?etcetera to /member146537.html?

I may be missing the point here, but any extra clarification would be appreciated!

I can navigate to your profile page in Daniweb,
I can view it, unless I am logged in as you I cant edit it,

this is what user control scripts do.

I cant be sure, .htaccess mod_rewrite is seamless invisible to the user, but it is hugley unlikely that Daniweb keeps 500000 odd static html pages, when the database can fill in the blanks in a template page so easiliy

RewriteEngine On
RewriteRule /profiles/(*).html /profiles.php?user=$1 [R,NE]

(untested possible syntax errors too lazy to check the format) should redirect all /profiles/xxxxx.html to profiles.php?user=xxxx , its as simple as that

Almostbob - you're a superstar! Many thanks for your advice.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.