|
Posted by student4life on July 2, 2009, 9:43 pm
Please log in for more thread options
Hello,
If I have self-submitting page that will have the data fields
refreshed/updated ONLY when the data are different between each
submission, could someone show me what the best way is to accomplish
this task? I was thinking using $_SESSION variable and compare the
stored value to that of the $_REQUEST variable and proceed with
database operations only when there is a difference. TIA
|
|
Posted by jeff on July 3, 2009, 1:34 am
Please log in for more thread options
student4life wrote:
show/hide quoted text
> Hello,
>
> If I have self-submitting page that will have the data fields
> refreshed/updated ONLY when the data are different between each
> submission,
I have to ask, what does it matter? If the data is the same, what
would it matter if it were overwritten. It's no less trouble to select
and compare than to just update. MySQL has REPLACE.
I assume there is something else?
Jeff
could someone show me what the best way is to accomplish
show/hide quoted text
> this task? I was thinking using $_SESSION variable and compare the
> stored value to that of the $_REQUEST variable and proceed with
> database operations only when there is a difference. TIA
|
|
Posted by C. (http://symcbean.blogspot.c on July 3, 2009, 7:29 am
Please log in for more thread options show/hide quoted text
> Hello,
> =A0 If I have self-submitting page that will have the data fields
> refreshed/updated ONLY when the data =A0are different between each
> submission, could someone show me what the best way is to accomplish
> this task? I was thinking using $_SESSION variable and compare the
> stored value to that of the $_REQUEST variable and proceed with
> database operations only when there is a difference. TIA
So the form submits itself but between times the user might have
changed something.
If you use a session then YOU ARE UPDATING THE (session) DATA EVERY
TIME ANYWAY.
I think the your objective is decidedly dubious, and your proposed
solution is innappropriate as per above. Assuming that your objective
is valid, then you could acheive it by including the original values
in one or more hidden form fields. This does make possible CSRF issues
would could be avoided by adding additional checks, e.g.
<?php
$prev=3D$_REQUEST['prev'];
unset($_REQUEST['prev'];
$payload_chk=3Dsha1(var_export($_REQUEST,true) . "s3cr3t"));
if ($payload!=3D$prev) {
update_date($_REQUEST); // data has changed
}
show/hide quoted text
print "<form method=3D'POST'>";
$payload_chk=3Dsha1(var_export($_REQUEST,true) . "s3cr3t"));
show/hide quoted text
print "<input type=3D=3D'hidden' name=3D'prev' value=3D'$old'>";
....show rest of form
C.
|
|
Posted by Gordon Burditt on July 6, 2009, 5:42 pm
Please log in for more thread options show/hide quoted text
>This current task I do is trivial so I can just do insert/replace to
>refresh the data for every request but I was just wondering for
>scenario that requires more costly database operations there would
>probably be a way to minimize the cost.
The database is likely to avoid writes if the data hasn't changed.
show/hide quoted text
>You indicated that the value
>needs to be stored/updated every time in $_SESSION (or temporary
>variable) anyway but the way I see is that it's going to be stored/
>updated only when it's different from the value in $_REQUEST, no? I
As I understand the way alternate session save handlers work, if
you've got a session, the session data will be saved at the end of
processing the page. No conditions. The value of anything in
$_REQUEST has nothing to do with it.
|
|
Posted by Jerry Stuckle on July 3, 2009, 8:44 am
Please log in for more thread options student4life wrote:
show/hide quoted text
> Hello,
>
> If I have self-submitting page that will have the data fields
> refreshed/updated ONLY when the data are different between each
> submission, could someone show me what the best way is to accomplish
> this task? I was thinking using $_SESSION variable and compare the
> stored value to that of the $_REQUEST variable and proceed with
> database operations only when there is a difference. TIA
What's the purpose you are trying to achieve? And where do you want to
update the data? Screen? Database? Mars? (Forget the last one :-) ).
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
|
| Similar Threads | Posted | | Updating the SQL key value | March 28, 2007, 9:50 am |
| Updating cookies | April 6, 2005, 8:20 pm |
| Updating Records | January 14, 2006, 8:34 pm |
| Updating MySQL with PHP | July 18, 2007, 12:00 am |
| No apxs when updating PHP | April 24, 2008, 5:12 pm |
| Updating an image | June 11, 2008, 10:25 am |
| Updating auto_increment fields ? | August 30, 2004, 11:47 am |
| apxs problem when updating PHP | September 26, 2004, 8:20 pm |
| Problem updating PHP Include? | August 17, 2005, 12:44 am |
| mySql updating numbers | September 19, 2005, 8:09 am |
|
>
> If I have self-submitting page that will have the data fields
> refreshed/updated ONLY when the data are different between each
> submission,