shortysbest Posted May 18, 2010 Share Posted May 18, 2010 I dont believe facebook or any big social networking site like that would create a whole new php page for every user that signs up. Right now i have to create a new php file but include the template with that page (in order to create the URL path) How else could this be done, i have had some ideas as to how to do this but any advice would be nice Quote Link to comment Share on other sites More sharing options...
anups Posted May 18, 2010 Share Posted May 18, 2010 U can use apache's mod rewrite function with .htaccess file, It will help you to solve your problem. Quote Link to comment Share on other sites More sharing options...
ignace Posted May 18, 2010 Share Posted May 18, 2010 You create one page and just retrieve the info you want to display on that page for a particular user. Quote Link to comment Share on other sites More sharing options...
shortysbest Posted May 18, 2010 Author Share Posted May 18, 2010 You create one page and just retrieve the info you want to display on that page for a particular user. I have this set up, just if i didnt have another php file for every user i wouldnt be able to link the users page to everyone. Now my url is index.php?node=(usersname)§ion=users Quote Link to comment Share on other sites More sharing options...
BizLab Posted May 18, 2010 Share Posted May 18, 2010 You create one page and just retrieve the info you want to display on that page for a particular user. I have this set up, just if i didnt have another php file for every user i wouldnt be able to link the users page to everyone. Now my url is index.php?node=(usersname)§ion=users hey, you will most likely want to replace the "node=username" with a user id from the primary key of the database you are using to store that information. Each user has their unique data in the database. You will query for this info and populate your user-index.php page with it. You are using a database right? if not, there is no way to do what you want. Quote Link to comment Share on other sites More sharing options...
Mchl Posted May 18, 2010 Share Posted May 18, 2010 You are using a database right? if not, there is no way to do what you want. You want me to prove you wrong? Unless by database you mean 'data stored somehow'. Quote Link to comment Share on other sites More sharing options...
gwolgamott Posted May 18, 2010 Share Posted May 18, 2010 You are using a database right? if not, there is no way to do what you want. You want me to prove you wrong? Unless by database you mean 'data stored somehow'. It would probably be fun & entertaining.... You create one page and just retrieve the info you want to display on that page for a particular user. I have this set up, just if i didnt have another php file for every user i wouldnt be able to link the users page to everyone. Now my url is index.php?node=(usersname)§ion=users Look up dynamic pages, I think this is what you are confused on. You create a master or main page that changes based on who's logged in, what they clicked... etc... thus one page that creates a template. That is changed with the script everytime it's loaded specifically. So instead of storing an entire page you store one page and a few lines in a file or database someplace that mark the customization for that page. So yes and no they create a new page for every user but it is done on the fly made up of one master file (one on the server not per user mind you, so instead of 100 page for 100 users you have 1 page and store 100 bits of information elsewhere.) and components from a database to make it appear as it should to a particular user. So the php script would go Quote Link to comment Share on other sites More sharing options...
shortysbest Posted May 18, 2010 Author Share Posted May 18, 2010 You are using a database right? if not, there is no way to do what you want. You want me to prove you wrong? Unless by database you mean 'data stored somehow'. It would probably be fun & entertaining.... You create one page and just retrieve the info you want to display on that page for a particular user. I have this set up, just if i didnt have another php file for every user i wouldnt be able to link the users page to everyone. Now my url is index.php?node=(usersname)§ion=users Look up dynamic pages, I think this is what you are confused on. You create a master or main page that changes based on who's logged in, what they clicked... etc... thus one page that creates a template. That is changed with the script everytime it's loaded specifically. So instead of storing an entire page you store one page and a few lines in a file or database someplace that mark the customization for that page. So yes and no they create a new page for every user but it is done on the fly made up of one master file and components from a database to make it appear as it should to a particular user. Yeah, the way i am doing it right now is when a user creates an account on my website, i take their name they input into their name field and i use that to automatically create a php inside the users folder and it automatically writes the <?php include('usertemplate.php'); ?> inside each file. In the usertemplate.php file each variable changes upon the specified usersname that is input into my url which is, index.php?node=(user's name)§ion=users, users being the folder in which it is stored. What i have been trying to do is to get it to get the user's name from my database and add that to the url so i wouldnt have to have many php files. like for facebook they would have to have over 500million files inside of a folder, which just doesn't seem like the best way to deal with this. Quote Link to comment Share on other sites More sharing options...
jdavidbakr Posted May 18, 2010 Share Posted May 18, 2010 Facebook uses a database to store all the info, which is certainly the cleanest way to handle it. If you're dealing with a very complicated set of data, you'll probably want to do some study on database design. Quote Link to comment Share on other sites More sharing options...
BizLab Posted May 18, 2010 Share Posted May 18, 2010 You are using a database right? if not, there is no way to do what you want. You want me to prove you wrong? Unless by database you mean 'data stored somehow'. Well i didn't mean ABSOLUTELY no way...just not a way that he would WANT to do it ... EG: storing files - the mysql db is just a tad quicker... Anyway SortysBest:: I'd suggest grabbing a Newbee friendly book for php & mysql like Head First PHP& Mysql. They explain how to do what you are doing in one of the chapters. Quote Link to comment Share on other sites More sharing options...
Mchl Posted May 18, 2010 Share Posted May 18, 2010 Well i didn't mean ABSOLUTELY no way...just not a way that he would WANT to do it ... Quote Link to comment Share on other sites More sharing options...
gwolgamott Posted May 18, 2010 Share Posted May 18, 2010 Yeah, the way i am doing it right now is when a user creates an account on my website, i take their name they input into their name field and i use that to automatically create a php inside the users folder and it automatically writes the <?php include('usertemplate.php'); ?> inside each file. Does that mean you create a php script for each person? Why are you doing that? If you are that's the problem right there, do not create a php file for each user. That is not necessary. It's like having a duplicate of the same file over and over just with different names attached to it. What they do is this.... one file... Uno... no more is used by everyone. What you store for a user is this, say we have a table in a database called users. This table would be like so: USER TABLE [userID] [Name] [Page color] [user pic] bobo01 Bob Red dfsd.gif Jake34 Jake Thomas blue sdfs.jpg For a simple page you'd store just the color, name, image & user id So when someone comes to the site they get a log in page this page runs a script that after they are logged in goes to the user table and says ok this page should display Bob background color Red and display dfsd.gif But if Jake is logged in displays Jake Thomas blue background & displays sdfs.jpg They used the same page & everyone user there will use the same page, just the stuff in the table triggers the script to display it differently depending on who is logged in. You don't store separate php pages Quote Link to comment Share on other sites More sharing options...
shortysbest Posted May 18, 2010 Author Share Posted May 18, 2010 Yeah, the way i am doing it right now is when a user creates an account on my website, i take their name they input into their name field and i use that to automatically create a php inside the users folder and it automatically writes the <?php include('usertemplate.php'); ?> inside each file. Does that mean you create a php script for each person? Why are you doing that? If you are that's the problem right there, do not create a php file for each user. That is not necessary. It's like having a duplicate of the same file over and over just with different names attached to it. What they do is this.... one file... Uno... no more is used by everyone. What you store for a user is this, say we have a table in a database called users. This table would be like so: USER TABLE [userID] [Name] [Page color] [user pic] bobo01 Bob Red dfsd.gif Jake34 Jake Thomas blue sdfs.jpg For a simple page you'd store just the color, name, image & user id So when someone comes to the site they get a log in page this page runs a script that after they are logged in goes to the user table and says ok this page should display Bob background color Red and display dfsd.gif But if Jake is logged in displays Jake Thomas blue background & displays sdfs.jpg They used the same page & everyone user there will use the same page, just the stuff in the table triggers the script to display it differently depending on who is logged in. You don't store separate php pages I only create a new php file to get the url so other people can see the page, it is only to get the users id, i do not know how to do this, or i cant get it to work anyways. however i do have it so in the edit your profile section it only changes upon who's logged in, using only one file for all users. my url is like so: www.mysite.com/index.php?node=shortysbest§ion=users in this case the php file would be called shortysbest stored in a folder called users. What i cant quite figure out how to do is to instead replace shortysbest(invisible '.php) with the 'name' field in my database. Quote Link to comment Share on other sites More sharing options...
Mchl Posted May 18, 2010 Share Posted May 18, 2010 Do you know how $_GET array works? http://php.net/manual/en/reserved.variables.get.php Quote Link to comment Share on other sites More sharing options...
gwolgamott Posted May 18, 2010 Share Posted May 18, 2010 I only create a new php file to get the url so other people can see the page, it is only to get the users id, i do not know how to do this, or i cant get it to work anyways. however i do have it so in the edit your profile section it only changes upon who's logged in, using only one file for all users. my url is like so: www.mysite.com/index.php?node=shortysbest§ion=users in this case the php file would be called shortysbest stored in a folder called users. What i cant quite figure out how to do is to instead replace shortysbest(invisible '.php) with the 'name' field in my database. Oh ok, you can do this a number of ways then. $_GET is probably best way. For other people to see the page, you can create a script that runs openly so say they enter http://mysite.php/?name=Bobo then the script runs a non-logged in script for public viewing, and does same thing as you did with the log in portion, just it takes the Bobo as value and then use that variable to pull info from the database. Take a look at the link Mchl sent yah Quote Link to comment 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.