I have 3 pages a.php ,b.php and c.php .How can I use the variable of b.php in c.php


a.php

<script type="text/javascript">
var width;
width = screen.width;
if (width > 0) {
location.href = "b.php?width=" + width;
} else 
    exit();
</script>

b.php

<?php

if($_GET['width'])
{
public $screen_width;
$screen_width=$_GET['width'];
}

else
{
include("a.php");
}
?>

c.php

<?php 
global $screen_width;

 if($screen_width>1024)
{
.....
}

else

{...

}

?>

Help me guys,I can't use include() since a.php has js that keeps reloading everytime and c.php will be redirected to c.php?width=...

use sessions:for example:

b.php

$var="hello";
session_start();
$_SESSION['var']=$var;

c.php

session_start();
echo $_SESSION['var'];

Enjoy!

Its not working, just blank page is being displayed when i open c.php .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.