Digital Point Forums
Send Money Online

Go Back   Digital Point Forums > Design & Development > Programming > PHP
Google Analytics
Log In to view
your analytics

Reply
 
Thread Tools
  #1  
Old May 9th 2008, 12:59 am
psyphil psyphil is offline
Peon
 
Join Date: Dec 2007
Location: Bangalore
Posts: 6
psyphil is on a distinguished road
Question HOW to pass php variable from one page to other

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
Code:
<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 Code:
<?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 Code:
<?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=...
Reply With Quote
  #2  
Old May 9th 2008, 1:33 am
ksamir2004 ksamir2004 is offline
Grunt
 
Join Date: Mar 2008
Posts: 70
ksamir2004 is on a distinguished road
Hi..

you can use cookie to store value..

Quote:
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
__________________
Thanks,
Sam

Last edited by ksamir2004; May 9th 2008 at 1:41 am.
Reply With Quote
  #3  
Old May 9th 2008, 2:24 am
psyphil psyphil is offline
Peon
 
Join Date: Dec 2007
Location: Bangalore
Posts: 6
psyphil is on a distinguished road
Question Re: HELP me pass php variable from a page to other

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
Reply With Quote
  #4  
Old May 9th 2008, 2:35 am
ksamir2004 ksamir2004 is offline
Grunt
 
Join Date: Mar 2008
Posts: 70
ksamir2004 is on a distinguished road
Quote:
Originally Posted by psyphil View Post
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.
__________________
Thanks,
Sam
Reply With Quote
  #5  
Old May 9th 2008, 4:51 am
lanmonkey lanmonkey is offline
Hand of A'dal
 
Join Date: May 2007
Posts: 460
lanmonkey is on a distinguished road
use sessions, much simpler and your not sending your data across the net multiple times
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
NEED help to pass javascript variable to php psyphil Programming 1 May 9th 2008 4:25 am
how to pass javascript variable into php session goutam.dutta123 PHP 6 Oct 16th 2007 12:51 am
easy ? for you php heads pass a variable create a directory kool-aid PHP 1 Oct 8th 2007 7:48 pm
Javascript variable into php variable without updating page? colin008 JavaScript 3 Aug 9th 2007 4:01 am
is it possible to pass a php variable to asp code white10 PHP 6 Apr 20th 2007 5:09 am


All times are GMT -8. The time now is 9:33 pm.