Go Back   SitePoint Forums > Forum Index > Program Your Site > PHP
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Jul 4, 2005, 14:41   #1
ddragas
SitePoint Member
 
Join Date: May 2004
Location: Croatia
Posts: 3
Mozilla Firefox PROBLEM ???

I still don't get why is this hepening. If I'm browsing (testing) on local machine with IE 6 everithing is woorking nice, but if I'm browsing with Mozilla Firefox I get double records inserted into db, and everything that has something to do with database (update or insert) is is doing it double or twice.

here are two tables

FIRST TABLE
zaglavlje_ponuda

broj int(11)
datum varchar(12)
trajanje varchar(12)
kupac int(11)
id int(11) - primary k

SECOND TABLE
stavke_ponude

id int(11) - primary k
broj int(11)
sifra text
opis longtext
kolicina text
cijena text
popust text
vrijednost text
porez text
ukupno text


and this is code

PHP Code:

<?

session_start
();
$broj_ponude = $_SESSION['broj_ponude'];
?>
<?

echo "Broj ponude: " . $broj_ponude;

        
$id = $_GET['id'];

        include(
'../stranice/con_db.php');
        
        
$result = mysql_query("SELECT * from proizvodi where id = '$id'") or die (mysql_error());
        
$row = mysql_fetch_array($result);
        
        
$sifra = stripslashes($row["sifra"]);
        
$naziv = stripslashes($row["opis"]);
        
$cijena1 = $row["cijena"];
        
        
$datum = time();
        
$dana = 8;
        
$sati = 24;
        
$minuta = 60;
        
$sekunda = 60;
        
$valuta = $dana * $sati * $minuta * $sekunda;
        
        
mysql_free_result($result);
        
            if(!isset(
$broj_ponude))
                {

                    
$query_count_broj_ponude = mysql_query("select max(broj) as zadnji_broj_ponude from zaglavlje_ponuda ") or die (mysql_error());
                    
$result_row_broj_ponude = mysql_fetch_assoc($query_count_broj_ponude);
                    
$zadnji_broj = $result_row_broj_ponude['zadnji_broj_ponude'];
                    
                    
$novi_broj_ponude = $zadnji_broj + 1;
                    
                    
$broj_ponude = $_SESSION['broj_ponude'] = $novi_broj_ponude;
                    
                    
$query = "insert into zaglavlje_ponuda
                                    (broj, datum, trajanje) values
                                    ('$broj_ponude', '$datum', '$valuta')"
;
                    
mysql_query($query) or die (mysql_error());
                }

        
$slova=array(",");
        
$izmjena=".";
        
$cijena  = str_replace($slova, $izmjena, $cijena1);
        
        
$porez = $cijena * (18.0328 / 100);
        
$osnovica = $cijena - $porez;
        
$kol = 1;
        
$pop = 0;

        if(!empty(
$broj_ponude))
            {
                
$query = "insert into stavke_ponude
                                (broj, sifra, opis, kolicina, cijena, popust, vrijednost, porez, ukupno) values
                                ('$broj_ponude', '$sifra', '$naziv', '$kol', '$osnovica', '$pop', '$osnovica', '$porez', '$cijena')"
;
                
mysql_query($query) or die (mysql_error());
            }
        include(
'../stranice/disconect.php');
        
?>
I would aprecheate if someone could help me or just give me a good direction of resolving this problem.

Already 3 days trying to resolve this problem

Please help me
ddragas is offline   Reply With Quote
Old Jul 4, 2005, 23:11   #2
Dylan B
Sitepоint Ninja
 
Dylan B's Avatar
 
Join Date: Jul 2004
Location: NYC
Posts: 1,155
It's not a PHP problem, browser has nothing to do with the PHP. What is happening, or so I think, is the form is being submited twice. Try setting a five second cookie on submit and check if it is set before the script runs.
Dylan B is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 13:48.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved