how do i create subdomain automatically

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
adsegzy
Forum Contributor
Posts: 184
Joined: Tue Jul 28, 2009 9:26 am

how do i create subdomain automatically

Post by adsegzy »

Hello friends,
i want a situation whereby when members confirm his registration a subdomain will be automatically created. eg if a member by name Mike Lawrence confirm his registration, a subdomain like www.mydomain.com/mikelawnrece OR mikelawrence.mydomain.com will be created, so that anyone can visit his profile by entering the subdomain in any address bar. pls what are the easiest ways of doing this.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: how do i create subdomain automatically

Post by pickle »

Your best bet would be to set up a *.yourdomain.com subdomain, and have it forward to your regular www.yourdomain.com website. In your index.php file, check what the subdomain is & show the appropriate stuff based on that.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
adsegzy
Forum Contributor
Posts: 184
Joined: Tue Jul 28, 2009 9:26 am

Re: how do i create subdomain automatically

Post by adsegzy »

Pls do you have any tutorial for that, i need one to put me through. thanks
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: how do i create subdomain automatically

Post by pickle »

I think CPanel is the easiest way to set up a subdomain. If you don't have access to that, talk to your hosting provider & tell them what you want to do.

As far as examining the url in PHP, look into the $_SERVER superglobal.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply