Jump to content

Recommended Posts

Posted

Hi

I'm new to html and PHP and ended up coming to a point where I have no more knowledge and the Internet solutions don't work...

 

So I’m trying to do a simple PHP-redirect after a mobile detection:

 

<?php
// Include the mobile device detect class
require_once 'Mobile_Detect.php';
// Init the class
$detect = new Mobile_Detect;
// checking if the user comes with a mobile device
if ($detect->isMobile()) {
   // Detects any mobile device.
   // Redirecting
   header("Location: http://www.ahornung.heliohost.org/mob");}
   else 
   {header("Location: http://www.ahornung.heliohost.org/pc");}
?>   


Well on my PC, it’s a XAMPP-Server, I get my redirect but on the online-Server (Helios) I get this back:

Warning: Cannot modify header information - headers already sent by

 

So I hope someone could help me.

Thanks for your help

 

adho12

 

p.s. Sorry for my English

  • Like 1
Posted

Is there any html before your php redirect code? There can't be any content sent before the header redirect.

Posted

<html>
<head>
</head>
<body>
<?php
// Include the mobile device detect class
require_once 'Mobile_Detect.php';
// Init the class
$detect = new Mobile_Detect;
// And here is the magic - checking if the user comes with a mobile device
if ($detect->isMobile()) {
   // Detects any mobile device.
   // Redirecting
   header("Location: http://www.ahornung.heliohost.org/mob");}
   else
   {header("Location: http://www.ahornung.heliohost.org/pc");}
?>  
WEITERLEITUNG FOLGT!
</body>
</html>

 

This is the rest of the Code, so No html...

Posted

Yes that's html. You can have html in your script but you can't have it before the header redirect.

Guest
This topic is now closed to further replies.
×
×
  • Create New...