I have a web page where I want to rotate images from a gallery. The page loads the image via GET. There is a form on that page with two buttons - Rotate Left and Rotate Right- that use POST. When the page loads, if there is a value for 'rotate' from the form buttons, a function is called and image is rotated. It works fine, but my problem is that the rotated image only shows up immediately in IE. And in other browsers, refreshing the page displays the new image but because the POST data is still there, it also rotates the image again. This is fine for me since I know what is happening, but when it comes to allowing others to rotate their own images, well you know. I'm still new to all this, so if I missed something obvious please accept my humble apology. But I could really use some help here.
Thanks in advance
Here is the code, just in case
<?php
include('functions/Image.php');
if (isset($_GET['input'])){
$input=$_GET['input'];
}else{
$input="images/test/IMG_0967.jpg";
}
echo "Input= ".$input."<br />";
print '<pre>';
print_r($_POST);
print '</pre>';
function henry($r){//That's my son's name. Couldn't think of anything else at the time.
global $input;
$N = new Image($input);
$N->rotate($r);
$N->save();
$N->destroy();
}
if (isset($_POST['rotate'])){
if($_POST['rotate']=='RotateLeft'){
henry(90);
}elseif($_POST['rotate']=='RotateRight'){
henry(-90);
}
}else{
echo 'POST is not set, image not rotated.';
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Edit Image</title>
</head>
<body>
<p><img src=<?php echo $input; ?>>
</p>
<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?input=<?php echo $input; ?>">
<input type="submit" name="rotate" id="rotate" value="RotateLeft">
<input type="submit" name="rotate" id="rotate" value="RotateRight">
</form>
<?php
print '<pre>';
print_r($_POST);
print '</pre>';
echo "<br />";
echo "Input=: ".$input;
?>
</body>
</html>