PHP Error Adding Services to Hosts

Support requests, bug reports, questions etc.
JarekG
Re: PHP Error Adding Services to Hosts

Post by JarekG » Fri Jun 05, 2009 17:04

Hi,

When are you expecting to get it sorted ?
What exactly causes that problem ?

I avoided it temporary by removing error lines and set it something like that:

Code: Select all

elseif( isset($_POST["add_service"]) ){
    if( $_SESSION["count"] == $check_count){
        // Add Service (button clicked)
        require_once 'include/add_item_step2_write2db.php';
    }else{
        // refresh of site not allowed
        require_once 'include/add_item_step2_write2db.php';
So I avoided to check that one variable at all.

Regards,
Jarek

User avatar
fgander
NConf developer
NConf developer
Posts:308
Joined:Mon Mar 16, 2009 14:23
Location:Bern, Switzerland
Contact:

Re: PHP Error Adding Services to Hosts

Post by fgander » Fri Jun 05, 2009 17:44

thats a solution, if there are no other problems...

but the thing that the counter is not correct, is really strange !
never had it by myself...

must be something very special... :oops:
F.G. - NConf developer
http://www.nconf.org
Image
Follow NConf on Twitter!

JarekG

Re: PHP Error Adding Services to Hosts

Post by JarekG » Tue Jun 09, 2009 16:59

Do you presume it can be something with PHP or maybe any missing extension in PHP ? My version is

Code: Select all

PHP 5.2.9 (cli) (built: May  5 2009 15:35:49)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
Regards,
Jarek

User avatar
fgander
NConf developer
NConf developer
Posts:308
Joined:Mon Mar 16, 2009 14:23
Location:Bern, Switzerland
Contact:

Re: PHP Error Adding Services to Hosts

Post by fgander » Wed Jun 10, 2009 09:16

i really do not know what the problem is (the code should be just fine..., i do not understand why it does not work on a few systems...
its a really basic thing, and should really not be a problem of a php version, but hey , i am really confused about this... :roll:

ready my descritption here: if you knowing php it should really not be a problem...
fgander wrote:ok, so i will try to explain what my idea was , and how i implemented that in NConf... :roll:

mainly its a not "must have" mechanism... i just wanted to know, that people cannot resent data with the F5 / resending POST data, so that data may be corrupted in database and also to avoid duplicated entries...

so my idea was, to have a session "counter", an session variable which increases (+1) on every page load.
the code is at the top of the include/head.php:

Code: Select all

session_start();

// no Form-resending when browser refresh with button or F5
if ( isset($_SESSION["count"]) ){
    $_SESSION["count"]++;
}else{
    $_SESSION["count"] = 1;
}
now to have a value which will tell me, if the form was submitting correct, or resend with F5/refresh, i put the counter into an hidden input value:
modify_item_service.php
Row: 122

Code: Select all

<input name="HIDDEN_count" type="hidden" value="<?php echo ($_SESSION["count"] + 1);?>">
:!: important is the + 1, because, when you submit the form, on next page the session will also be increased, so both values should then be the same.

these is checked here:
Row: 21

Code: Select all

$check_count = $_POST["HIDDEN_count"];
Row: 47

Code: Select all

if( $_SESSION["count"] == $check_count){
-> writes data into database
else it will display the error/debug message

This of course will only work when i set the counter in the hidden input increased with one...

example, when i add a service, the session counter is 10, the hidden counter(in the form) should be 11 (increased with one)
so when click on Add, the post data will saved, because the session counter now also is increased with one, and both are 11 (or should be)...

so, when you press F5 you will submit the "old" POST data, the session counter otherwise will be increased with one again, so the session counter now is 12 , and your form submitts 11, this should avoid saving the data to the db...

now, i hope you understand me idea...
Do you have some idea, why this is not working correct at your installation ?
:!: ( to avoid problems, don't use NConf with multi tabs, the session data could work incorrect.. ) could there be an other variable like $_SESSION["count"] which makes NConf problems at your location?

Thanks for your help ;)

any ideas to improve that is welcome... (or just debug) :evil:
F.G. - NConf developer
http://www.nconf.org
Image
Follow NConf on Twitter!

JarekG

Re: PHP Error Adding Services to Hosts

Post by JarekG » Thu Jun 11, 2009 11:16

fgander wrote:any ideas to improve that is welcome... (or just debug) :evil:
I'm not a good in programming at all, that's why can give you just only an idea without a code ;).

The best to do if you want tu check such a thing and prevent clicking F5 by users is to implement adding these things in AJAX ;).
You won't need to check anything because even if user click F5 AJAX will not rewrite it because its "HTTP session" will be empty (data had been sent before F5 was pressed).

Regards,
Jarek

User avatar
fgander
NConf developer
NConf developer
Posts:308
Joined:Mon Mar 16, 2009 14:23
Location:Bern, Switzerland
Contact:

Re: PHP Error Adding Services to Hosts

Post by fgander » Thu Jun 11, 2009 13:15

thats of course a nice idea! thx

will check this, but the way it is coded at the moment, it should work (and it works on near all users.. expect a few people).
i really like to know where the problem really is.. ;)

regards fabian
F.G. - NConf developer
http://www.nconf.org
Image
Follow NConf on Twitter!

Locked