473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

my 1st use of session variables

I've written some code to overlay a transparent png over a jpeg, 4 4
links then allow the png to be moved, the x and y coordinates being
stored in $_SESSION.
It seems to work fine on my own local server but only intermitently
when live.
The full source with images is stored in
http://www.pherber.com/test/test.zip

Any help would be much appreciated.

index.php:
<?php session_name("pwh_test_session"); session_start(); ?>
<html><head><title>Test page</title>
<meta name="author" content="Paul Herber">
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-15">
<style type="text/css">
.mtitle {font-size:24pt; font-family:arial,helvetica,sans-serif}
.mtext {font-size:10pt; font-family:arial,helvetica,sans-serif}
</style>
</head>
<body bgcolor="#FFFFEC">
<div class=mtext align="center">

<?php
$_SESSION['x'] = 0;
$_SESSION['y'] = 0;
?>

<table border="0" align="center">
<tr><td>Starting session named <?php echo session_name();
?></td></tr>
<tr><td colspan="4" align="center"><a
href="show.php">Start</a></td>
</tr>
</table>

</div>
</body>
</html>

show.php:
<?php session_start(); ?>
<html><head><title>Test page</title>
<meta name="author" content="Paul Herber">
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-15">
<style type="text/css">
.mtitle {font-size:24pt; font-family:arial,helvetica,sans-serif}
.mtext {font-size:10pt; font-family:arial,helvetica,sans-serif}
</style>
</head>
<body bgcolor="#FFFFEC">
<div class=mtext align="center">

<?php
$d = $HTTP_GET_VARS['d'];
?>

<table border="0" align="center">
<tr>
<td colspan="4" align="center"><img class=mborder2 width="500"
height="375" border="0" title="" alt=""
<?php echo "src=\"showimage.php?d=$d\">";?></td></tr>
</tr>
<tr>
<td width="25%" align="center"><a href="show.php?d=u">Up</a></td>
<td width="25%" align="center"><a
href="show.php?d=d">Down</a></td>
<td width="25%" align="center"><a
href="show.php?d=l">Left</a></td>
<td width="25%" align="center"><a
href="show.php?d=r">Right</a></td>
</tr>
<tr><td colspan="4" align="center">
<?php echo 'x = ' . $_SESSION["x"] . ' y = ' . $_SESSION["y"];
?>
</td></tr>
<tr><td colspan="4" align="center">
<?php
if (($_SESSION["x"]==346) and ($_SESSION["y"]==180) ):
echo 'You have been hit for 6!';
endif;
if (($_SESSION["x"]==306) and ($_SESSION["y"]==240) ):
echo 'Batsman is out LBW';
endif;
if (($_SESSION["x"]==186) and ($_SESSION["y"]==220) ):
echo 'Bowled - middle stump!';
endif;
?>
</td></tr>
</table>

</div>
</body>
</html>

shopimage.php:
<?php
session_start();
$d = $HTTP_GET_VARS['d'];

$im1 = imagecreatefromJPEG('P6200007.jpg');
$im2 = imagecreatefromPNG('redball.png');

if ($d == 'u'): { $_SESSION["y"] = $_SESSION["y"] - 20; }
elseif ($d == 'd'): { $_SESSION["y"] = $_SESSION["y"] + 20; }
elseif ($d == 'l'): { $_SESSION["x"] = $_SESSION["x"] - 20; }
elseif ($d == 'r'): { $_SESSION["x"] = $_SESSION["x"] + 20; }
else: {
$_SESSION["x"] = imagesx($im1) - imagesx($im2)/2;
$_SESSION["y"] = imagesy($im1)/2 - imagesy($im2)/2; }
endif;
// check limits
if ($_SESSION['y'] < 0): $_SESSION['y'] = 0;
endif;
if ($_SESSION['y'] > imagesy($im1)-imagesy($im2)): $_SESSION['y'] =
imagesy($im1)-imagesy($im2);
endif;
if ($_SESSION['x'] < 0): $_SESSION['x'] = 0;
endif;
if ($_SESSION['x'] > imagesx($im1)-imagesx($im2)): $_SESSION['x'] =
imagesx($im1)-imagesx($im2);
endif;
imagecopy($im1, $im2, $_SESSION["x"], $_SESSION["y"], 0, 0,
imagesx($im2), imagesy($im2));

$mime="image/jpeg";
header("Content-Type: $mime");
header("Content-Disposition: filename=overlayedimage.jpg");

imageJPEG($im1);
imageDestroy($im1);
imageDestroy($im2);
?>
--
Regards, Paul Herber, Paul Herber Systems Ltd. http://www.pherber.com/
SanDriLa - SDL/MSC application for Visio
email address is spam-trapped - s/*@/paul@/
Jul 17 '05 #1
0 1465

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Al Jones | last post by:
This is a repost form the vbscript newgroup - if this isn't the appropriate group would you point me toward one that is. Basically, I seem to be losing session data part way though preparing an...
6
by: Lina Manjarres | last post by:
Hello, I have a session variable in a login page. Then I go to a form page where I uses the ProfileID and the UserID. Then I go to a result page where I would like to use the UserID as a filter,...
4
by: PJ | last post by:
A particular page seems to be having issues with correctly setting Session variables. I am setting a couple of session variables on the Page_Unload event. While stepping through code, the...
31
by: Harry Simpson | last post by:
I've come from the old ASP camp where session variables were not used. When i started using ASP.NET in 2001, I started using them again because it was ok from what I'd read. I've been merrily...
10
by: tshad | last post by:
I have been using the default session state (InProc) and have found that I have been loosing my information after a period of time (normally 20 minutes). Is there anyway to find out how much...
3
by: Alan Wang | last post by:
Hi there, Once my application gets complicated and complicated. I found it's really hard to keep track of Session value I am using in my asp.net application. I am just wondering if anyone have...
3
by: Phillip N Rounds | last post by:
I'm writing a user control which has two states: Active & InActive. I additionally am required that there to be only one active control per page, and all logic has to be contained within the...
18
by: BillE | last post by:
When a user opens a new IE browser window using File-New-Window the integrity of an application which relies on session state is COMPLETELY undermined. Anyone who overlooks the fact that...
26
by: BillE | last post by:
Some ASP.NET applications use Session Variables extensively to maintain state. These should be re-written to use viewstate, hidden fields, querystring, etc. instead. This is because if a user...
12
by: MrHelpMe | last post by:
Hello again all, I've finished my whole application and now I don't like the whole session variables that I am using. I have a form, user fills in info clicks submit and using CDOSYSMail an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.