Page 1 of 1

page load

Posted: Mon Jul 19, 2010 6:39 am
by roice
Hello,
I built PHP function that recognize if the user OS is mobile or regular computer. if its mobile the script will redirect the user to the site mobile version. the problem is that the site first got loaded and than after it finish it redirect the user to the mobile version.
How can I set it so my PHP function will load first?

Thank you in advance,
Roi.

Re: page load

Posted: Mon Jul 19, 2010 8:02 am
by dejvos
Do you redirect by header() function?

The code bellow could work.

Code: Select all

<?php
if(is_mobile($_SERVER)){
header('Location: mobile.site.com');
exit;
}else{
show_page();
}
?>

Re: page load

Posted: Mon Jul 19, 2010 8:22 am
by roice
Thanks dejvos,
Do I have to put the header code in the top of my page/code?
Imean- before I print anything to the screen...?

Re: page load

Posted: Mon Jul 19, 2010 8:32 am
by dejvos
Yes that's it,

you can manipulate with a header before you print anything else.

Re: page load

Posted: Mon Jul 19, 2010 8:46 am
by roice
OK, so I must put it in the top of my pages.
By the way, is there any chance that you know how to write the code above in ASP?

Re: page load

Posted: Tue Jul 20, 2010 1:59 am
by dejvos
Unfortunately I don't know that. Try google.

Re: page load

Posted: Tue Jul 20, 2010 4:04 am
by roice
OK,
Thank you!