Re-directing to sub domains

PJMFD 01 Jul, 2009
Hi
I am putting a website together for a client who wants to have a form for their clients to login to their own sub domains.

For example, form sits on http://www.mainwebsite.com
Their client goes to a login page on the main website, where they fill in a form for Client Name, Username and Password ( the UN and PW will be issued manually to each client)

By using the On submit code (after sending email) I would like the form to redirect the user to the correct sub domain by using the Client Name field as part of the redirect URL
For example clientname.mainwebsite.com
Be nice to also pass the UN and PW as well so I can make the pages on the sub domain for Registered users only!

All would be running on Joomla 1.5.10 using the latest version of ChronoForms

Many Thanks
Peter
Max_admin 02 Jul, 2009
Hi Peter,

this is easy, example:


<?php
global $mainframe;
$mainframe->redirect(JRequest::getVar('name').'.mydomain.com');
?>


where "name" is the client field name! you can add more data the same way!

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
frydesign 21 Jul, 2009
Hello,
I'm trying to use the code snippet

<?php
global $mainframe;
$mainframe->redirect(JRequest::getVar('name').'.mydomain.com');
?>


However, the redirect becomes mydomain.com/name.mydomain.com.

What do I need to do so that it is just the subdomain that is redirected.

Regards.
GreyHead 21 Jul, 2009
Hi frydesign,

I think that you'll have to add the full URL http://. . . into the redirect - otherwise Joomla (or the browser) will treat it as being relative to the current site.

Bob
frydesign 21 Jul, 2009
thanks for the quick response.

I don't know php syntax. How do I integrate 'http://' into the code snipped shown above.

Thanks again
-Andrew
GreyHead 22 Jul, 2009
Hi Andrew,

Try
$mainframe->redirect('http://'.JRequest::getVar('name').'.mydomain.com');

Bob
frydesign 22 Jul, 2009
Thanks so much. The solution can look soooooo simple sometimes.

Regards,
-Andrew
frydesign 22 Jul, 2009
This code works to redirect to the subdomain:
<?php
global $mainframe;
$mainframe->redirect('http://'.JRequest::getVar('username').'.mydomain.com');
?>


I also need to pass the username and the password since the subdomain is username/password protected.

Can you help with this.

Thanks,
-Andrew
GreyHead 22 Jul, 2009
Hi Andrew,

Errr . . . I've no idea - can you pass them in a URL - I know that you can for FTP but don't know about HTTP. Sorry.

Bob
nml375 22 Jul, 2009
Hi Bob & Andrew,
If you are referring to the HTTP Auth mechanism, it's rather trivial, although considered very unsecure; simply create the url as follows:
http://user:pass@host.tld/path/to/file

However, if you are using some custom logon-form, you'd first have to check that this system allows the use of login credentials through GET requests (most, such as Joomla, use POST request, where the username and password is not shown in the url). If it does, it's a "trivial" matter of figuring out which field names are used, and construct your url as follows:
http://host.tld/path/to/file?field1=value1&field2=value2

There is, however, no way to craft an url that will contain "POST-style" data, you'll need to submit a form for this. Hence this won't work for redirects.

/Fredrik
frydesign 23 Jul, 2009
Thanks for your help.
-Andrew
This topic is locked and no more replies can be posted.