Debt Consolidation - Kamala Harris - Deaf Topics - Find jobs - Debt Consolidation

PDA

View Full Version : HOW to pass php variable from one page to other


psyphil
May 9th 2008, 12:59 am
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>

<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");
}
?>

<?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

{...

}

?>

<?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=...

ksamir2004
May 9th 2008, 1:33 am
Hi..

you can use cookie to store value..


1. $width=$_COOKIE["width"];
2. You can use hidden field also
($width=$_GET['width']; )
ie, <input name="id1" type="hidden" value="<?php echo $width;?>"> //if you are using html in b.php

psyphil
May 9th 2008, 2:24 am
When a visitor visits c.php I want php to go to b.php and send the variable to c.php ,Is that possible using cookies

ksamir2004
May 9th 2008, 2:35 am
When a visitor visits c.php I want php to go to b.php and send the variable to c.php ,Is that possible using cookies

As per my knowledge yu can use cookie to store value.

lanmonkey
May 9th 2008, 4:51 am
use sessions, much simpler and your not sending your data across the net multiple times