473,395 Members | 1,668 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,395 software developers and data experts.

problem with POST and if statements

I have an image viewing page which resizes an image to a sensible sizebefore
displaying. The user should then be able to choose "25% larger" or smaller
and the resized image display. The problem I am getting with the code below
is that whatever the POST variable value (and I have tested the value
changes correctly), the line marked with *** executes, ie the image gets
smaller. Am I missing some obvious subtlety with IF statements?

Also, when the page reloads, it still displays the previous (ie non-resized)
image, despite the fact that I have confirmed that the actual image in the
directory has changed size. Is it the case that the image has been cached by
the browser? If so, how do I force a reload?

TIA Gaz

if(isset($_POST['submitScale'])) {
if ($_POST['scale'] = "25% smaller") {
resizeImageByPercent($thumbLocation, "resized", 75);
}
else if ($_POST['scale'] = "25% larger") {
resizeImageByPercent($thumbLocation, "resized", 125);
}
else if ($_POST['scale'] = "full size") {
resizeImageByPercent($originalLocation, "resized", 100);
}
}

.....blah blah blah some code

<form action="imageview.php3?image_id=<?echo $row["image_id"]?>"
method="POST">
Make this image&nbsp;<select name="scale">
<option>25% smaller
<option>25% larger
<option>full size
</select>
<input type="submit" name="submitScale" value="Go!">
</form>
Jul 16 '05 #1
6 2378
"GazK" <to*****@blueyonder.co.uk> wrote in message
news:mk****************@news-binary.blueyonder.co.uk...
I have an image viewing page which resizes an image to a sensible sizebefore displaying. The user should then be able to choose "25% larger" or smaller
and the resized image display. The problem I am getting with the code below is that whatever the POST variable value (and I have tested the value
changes correctly), the line marked with *** executes, ie the image gets
smaller. Am I missing some obvious subtlety with IF statements?

Also, when the page reloads, it still displays the previous (ie non-resized) image, despite the fact that I have confirmed that the actual image in the
directory has changed size. Is it the case that the image has been cached by the browser? If so, how do I force a reload?


This is how I tell the browser not to cache something:

header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');

I think I got this out of the PHP manual when looking up how to use the
header() function. Oh, if you're serving images off of the file system (and
not through a database or other dynamic means), I've found it works to read
the file in using fread() and send it to the client with the appropriate
"Content-Type" header. I created a bandwidth meter in PHP that used an
image file to test the transfer rate between a client and my server. It
seemed that the easiest way to make sure the image was never cached by the
browser was to use PHP (and the non-caching headers) to send the file
manually. (I'm sure there's an Apache work-around, though.)

By the way, are you changing the "width" and "height" attributes of your
image tag on the front end?

HTH,
Zac
Jul 16 '05 #2
> I have an image viewing page which resizes an image to a sensible
sizebefore
displaying. The user should then be able to choose "25% larger" or smaller
and the resized image display. The problem I am getting with the code below is that whatever the POST variable value (and I have tested the value
changes correctly), the line marked with *** executes, ie the image gets
smaller. Am I missing some obvious subtlety with IF statements?

Also, when the page reloads, it still displays the previous (ie non-resized) image, despite the fact that I have confirmed that the actual image in the
directory has changed size. Is it the case that the image has been cached by the browser? If so, how do I force a reload?

TIA Gaz

if(isset($_POST['submitScale'])) {
if ($_POST['scale'] = "25% smaller") {
resizeImageByPercent($thumbLocation, "resized", 75);***
}
else if ($_POST['scale'] = "25% larger") {
resizeImageByPercent($thumbLocation, "resized", 125);
}
else if ($_POST['scale'] = "full size") {
resizeImageByPercent($originalLocation, "resized", 100);
}
}

....blah blah blah some code

<form action="imageview.php3?image_id=<?echo $row["image_id"]?>"
method="POST">
Make this image&nbsp;<select name="scale">
<option>25% smaller
<option>25% larger
<option>full size
</select>
<input type="submit" name="submitScale" value="Go!">
</form>

Jul 16 '05 #3
"GazK" <to*****@blueyonder.co.uk> wrote in message
news:nG*****************@news-binary.blueyonder.co.uk...
I have an image viewing page which resizes an image to a sensible sizebefore
displaying. The user should then be able to choose "25% larger" or smaller and the resized image display. The problem I am getting with the code

below
is that whatever the POST variable value (and I have tested the value
changes correctly), the line marked with *** executes, ie the image gets
smaller. Am I missing some obvious subtlety with IF statements?

Also, when the page reloads, it still displays the previous (ie

non-resized)
image, despite the fact that I have confirmed that the actual image in the directory has changed size. Is it the case that the image has been

cached by
the browser? If so, how do I force a reload?

TIA Gaz

if(isset($_POST['submitScale'])) {
if ($_POST['scale'] = "25% smaller") {
resizeImageByPercent($thumbLocation, "resized", 75);***
}
else if ($_POST['scale'] = "25% larger") {
resizeImageByPercent($thumbLocation, "resized", 125);
}
else if ($_POST['scale'] = "full size") {
resizeImageByPercent($originalLocation, "resized", 100);
}
}


There's your first problem. Use "==" for comparison, and "=" for
assignment. Assignment returns the value assigned.

-Zac
Jul 16 '05 #4

"Martin Wickman" <wi*****@hotbrev.com> wrote in message
news:bf************@ID-156202.news.uni-berlin.de...
Other than that, try a force reload of your browser to make sure you
dont have any nasty cache problems.


Kinda offtopic, but I didn't think POST requests were allowed to be cached
anyway.
Jul 16 '05 #5
In article <bf************@ID-194542.news.uni-berlin.de>, Leslie Hoare wrote:

"Martin Wickman" <wi*****@hotbrev.com> wrote in message
news:bf************@ID-156202.news.uni-berlin.de...
Other than that, try a force reload of your browser to make sure you
dont have any nasty cache problems.


Kinda offtopic, but I didn't think POST requests were allowed to be cached
anyway.


Well, try posting something and then reload. See, the browser keeps
the stuff cached. About 'allowed' or not. I dont know, but I would
guess that it's up to each browser to decide whether it should cache
and not.
Jul 16 '05 #6
doh! thanks, that fixed that part of the problem.

"Zac Hester" <ne**@planetzac.net> wrote in message
news:3f********@news.enetis.net...
"GazK" <to*****@blueyonder.co.uk> wrote in message
news:nG*****************@news-binary.blueyonder.co.uk...
I have an image viewing page which resizes an image to a sensible

sizebefore
displaying. The user should then be able to choose "25% larger" or smaller and the resized image display. The problem I am getting with the code

below
is that whatever the POST variable value (and I have tested the value
changes correctly), the line marked with *** executes, ie the image gets smaller. Am I missing some obvious subtlety with IF statements?

Also, when the page reloads, it still displays the previous (ie

non-resized)
image, despite the fact that I have confirmed that the actual image in the directory has changed size. Is it the case that the image has been

cached
by
the browser? If so, how do I force a reload?

TIA Gaz

if(isset($_POST['submitScale'])) {
if ($_POST['scale'] = "25% smaller") {
resizeImageByPercent($thumbLocation, "resized", 75);***
}
else if ($_POST['scale'] = "25% larger") {
resizeImageByPercent($thumbLocation, "resized", 125);
}
else if ($_POST['scale'] = "full size") {
resizeImageByPercent($originalLocation, "resized", 100);
}
}


There's your first problem. Use "==" for comparison, and "=" for
assignment. Assignment returns the value assigned.

-Zac

Jul 16 '05 #7

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

Similar topics

9
by: Bartosz Wegrzyn | last post by:
I need help with sessions. I createt set of web site for nav with authorization. first I go into main.php which looks like this: <?php //common functions include_once '../login/common.php';...
68
by: Marco Bubke | last post by:
Hi I have read some mail on the dev mailing list about PEP 318 and find the new Syntax really ugly. def foo(x, y): pass I call this foo(1, 2), this isn't really intuitive to me! Also I...
10
by: Chih-Hsu Yen | last post by:
I encountered a strange problem about switch-case statement. switch(cmd) { case 1: statements; break; case 2: statements; break; ... .... case 11: S1; S2; S3; statements;
37
by: priya | last post by:
Hi all, I am using strdup() in my c program..But I am having some pr0blem while using the free() in my c code.here I am pasting the my code. #include <stdio.h>
10
by: Saso Zagoranski | last post by:
hi, this is not actually a C# problem but since this is the only newsgroup I follow I decided to post my question here (please tell me where to post this next time if you think this post...
5
by: Darin L. Miller | last post by:
I'm not too good with advanced SQL queries, so please bear with me on this. I have a query with multiple joins that I am trying to get just the last 10 of each unique record (RecordID)...
5
by: =?Utf-8?B?Y2FyYm8=?= | last post by:
I am getting odd behavior in my code, first I thought it was caused by SP1 but now I have the same issue with a vanilla version of VS 2005. When I execute a function that contains an if statement....
16
by: =?iso-8859-1?q?|-|e|=5F|=5F_B0=DD?= | last post by:
hi all! I got a problem. I declared a SOCKET var in my C program but when i compiled the program it displayed like *--------------------------------------------------------------* *'SOCKET':...
30
by: Einstein30000 | last post by:
Hi, in one of my php-scripts is the following query (with an already open db-connection): $q = "INSERT INTO main (name, img, descr, from, size, format, cat, host, link, date) VALUES ('$name',...
9
by: John | last post by:
Hello all. I am a PHP newbie and am having an issue using the && in an if statement. here is the code: if ($_REQUEST == "1" && date("Y-m-d") < $rowWork) { die("<h1>The earlybird special has...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.