I want to create a website that has 1 standard look and pages for many different people with the only difference being the contact information. In other words I would have a website such as www.mydomain.com/bob for bobs website. On this website I would have a few sections that would need to display his contact information that is pulled from a MySQL database. However if someone was to type in www.domainname.com/alisa then I would need to have her contace info pull up on the website from the database. Is there any good solution to do this by generating the dynamic info from the name at the end of the URL? If so how would I go about doing this with php and mysql. I am a newbie at this so any info directed to someone who is inexperienced would be appreciated. Thanks for the help in advance
You're going to need to mod_rewrite your URLS, that is how you will accomplish the http://www.website.com/bob formatted urls. In laymans terms, mod_rewrite will allow you to "mask" your urls. For example, say you have: http://www.website.com/get_contact_info.php?name=bob Code (markup): You could use mod_rewrite to make it look like http://www.website.com/bob Code (markup): See the Apache documentation: http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html Or the Sitepoint article: http://www.sitepoint.com/article/guide-url-rewriting/ Now any name that you put in will be passed to get_contact_info.php for processing. You'll also need the basic mysql queries to grab any info you need. Something like: <? $name = mysql_escape_string($_GET['name']); // the wildcard * is not recommended, just pull what you need instead // but for the sake of this example i've used it :) $sql = "select * from TABLE_NAME where name='$name' limit 1"; $sql = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_assoc($sql); // all of your values in array $row[] ?> PHP: Hope that helps, Louis
Thanks Louis11. With what you described would I be able to make it work if someone who initiated or origially typed www.mysite.com/bob or www.mysite.com/alisa? What I want it to have one site but for many different reps so they can say to a client hey go check out my site at www.mysite.com/bob and it will pull their info up from the url that was originally typed in the browser.
I am working again on this project and would appreciate some additional help. Louis11 gave me some great info about mod_rewrite for URLS however I think what he suggest may not work because I don't know what the specific name would be at the end of the URL. Here is a more specific example. I would set up a landing page for real estate agents to come at to purchase a website and fill out some fields that would be saved in a MySQL database. The website would be the exact same site except on some pages there would be personal info like name, email address, phone# and what name that they want to have show up in the URL as. So if I purchase a site and fill out the info stating that I want my URL to be michael. I would promote my site by telling clients that they should go to www.mydomain.com/michael and by doing that the info with michael would be the identifier to what should be pulled from the database on the contact page. So since the name can be anything the suggestion that I got from Louis11 that said to use would not work because the last part of the URL "/michael" could be anything that a user picks. Any suggestions on how I would get this to work would be appreciated.