damerit Posted June 25, 2008 Share Posted June 25, 2008 When I use this code it will record the log events fine in Firefox. When I use it in ie it will often give me duplicate entries. So, if the code works fine in Firefox but not ie would it be browser related? If so, what would be the best way to handle logs when the page loads? Does anyone have an ideal of why it would work in Firefox and not ie? Should I use a different method of logging events when a link is clicked on? This site is internal with relative links. <?php session_start(); require_once('Connections.php'); mysql_select_db($database, $DB); $id = $_GET['id']; $userid = $_SESSION['userid']; $submitDate = date('Y-m-d H:i:s'); $q = "insert into log (id, logid, userid, timestamp) VALUES ('','$id', '$userid', '$submitDate')"; mysql_query($q, $DB) or die (mysql_error()); echo $id; ?> thanks. Quote Link to comment Share on other sites More sharing options...
.josh Posted June 25, 2008 Share Posted June 25, 2008 The code itself would not cause duplicate entries. But I really don't think it's a browser specific issue either, as the browser doesn't really have anything to do with your code and what it does. I think I would start looking at the code(s) that calls this. Quote Link to comment Share on other sites More sharing options...
ober Posted June 25, 2008 Share Posted June 25, 2008 PHP is not browser related. There is no way that the browser is affecting the submission of the entry. Either you're not showing us all the code or something else is screwing up. Why are you starting sessions if you're not using them (one reason why I think there is more code than this). Quote Link to comment Share on other sites More sharing options...
discomatt Posted June 25, 2008 Share Posted June 25, 2008 PHP is not browser related. There is no way that the browser is affecting the submission of the entry. Either you're not showing us all the code or something else is screwing up. Why are you starting sessions if you're not using them (one reason why I think there is more code than this). Unless the browser is requesting the page twice, perhaps? Quote Link to comment Share on other sites More sharing options...
.josh Posted June 25, 2008 Share Posted June 25, 2008 he is using sessions: $userid = $_SESSION['userid']; Quote Link to comment Share on other sites More sharing options...
ober Posted June 25, 2008 Share Posted June 25, 2008 Gahh... didn't notice that. The browser would not request the page twice... not on it's own. Quote Link to comment Share on other sites More sharing options...
.josh Posted June 25, 2008 Share Posted June 25, 2008 PHP is not browser related. There is no way that the browser is affecting the submission of the entry. Either you're not showing us all the code or something else is screwing up. Why are you starting sessions if you're not using them (one reason why I think there is more code than this). Unless the browser is requesting the page twice, perhaps? Going off that, I'd ask if he is somehow utilizing javascript and maybe it's possibly bugging in IE, causing it to submit twice. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 25, 2008 Share Posted June 25, 2008 The posted code unconditionally executes any time that page is requested. Things like URL rewriting, requesting favicons, and javascript duplicate form submission will cause the URL to be requested more than once. Unless you have some javascript form submission with a bug in it, you will need to solve this on the server by setting a session variable that says that the page has been executed once and skip over (or exit/die) the code once that variable has been set. Quote Link to comment Share on other sites More sharing options...
damerit Posted June 26, 2008 Author Share Posted June 26, 2008 Ok! I have checked everything from variables, sessions, to page reloads and I'm stummped... my index.php - uses an iframe to load the main.php and onLoads() a size function my main.php - pulls groups of data and toggles them for display my display.php - only inserts a log entry to the database but inserts duplicates every 2 or 3 or even 5th clicks. it is sparatic. I changed the session variables to local variables and assigned values to them and it still duplicates. sorry, this may be long... .............index.... <?php session_start(); $theman = "Admin"; $staff = "Staff"; $userid = $_SESSION['valid_user']; $fname = $_SESSION['firstName']; $lname = $_SESSION['lastName']; $stat = $_SESSION['status']; if(!isset($userid)){ header('Location: login.php'); } $localdate = date('l M d, Y'); ?> <html> <head> <title>Welcome ER Recovery Actions</title> <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <link HREF="CSS/dt_css.css" REL="stylesheet" TYPE="text/css"> <script language="javascript"> function size() { var oBody = document.getElementById('bodyid'); var oFrame = document.getElementById('timedata'); var oTable = document.getElementById('tabledata'); oFrame.height = oBody.clientHeight - ((oTable.offsetHeight*2)-10); //(oBody.offsetHeight - oBody.clientHeight); } </script> </head> <body onLoad="size();" onResize="size();" id="bodyid"> <table WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="white" id="tabledata"> <tr> <td align="left" width="10%" class="login"><table WIDTH="85" BORDER="0" CELLSPACING="0" CELLPADDING="0" BGCOLOR="white"> <tr> <td colspan="3" class="login"><img SRC="images/transparent.gif" ALT="" HEIGHT="14" WIDTH="24" BORDER="0"></td> </tr> <tr> <td class="login"><img SRC="images/transparent.gif" ALT="" HEIGHT="14" WIDTH="24" BORDER="0"></td> <td class="login"><img SRC="images/transparent.gif" ALT="" HEIGHT="14" WIDTH="24" BORDER="0"></td> </tr> <tr> <td colspan="3" class="login"><img SRC="images/transparent.gif" ALT="" HEIGHT="13" WIDTH="24" BORDER="0"></td> </tr> </table> </td> <td class="login"><img SRC="images/mark.gif" ALT="mark" BORDER="0"></td> </tr> </table> <table WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0"> <tr bordercolor="#000000" height="1"><td NOWRAP> </td><td NOWRAP> </td></tr> <tr bgcolor="#EEEEEE"><td NOWRAP><?php echo "Welcome ".$fname." ".$lname; ?></td><td NOWRAP align="right"><?php echo $localdate; ?></td></tr> </table> <table width="100%" BORDER="0"> <tr> <td width="10%" valign="top" align="left" class="display"> <br> <table height="100%" width="100%" align="left" border="0"> <tr class="RowOverOdd" onMouseOver="this.className='RowOverSelected';" onMouseOut="this.className='RowOverOdd';"><td nowrap><a href="index.php">Home</a></td></tr> <tr class="RowOverOdd" onMouseOver="this.className='RowOverSelected';" onMouseOut="this.className='RowOverOdd';"><td nowrap></td></tr> <tr class="RowOverOdd" onMouseOver="this.className='RowOverSelected';" onMouseOut="this.className='RowOverOdd';"><td nowrap></td></tr> <!--------------------------- dd ------------------------------------------------> <tr class="RowOverOdd" onMouseOver="this.className='RowOverSelected';" onMouseOut="this.className='RowOverOdd';" align="center"><td nowrap><b>dd</b></td></tr> <tr class="RowOverOdd" onMouseOver="this.className='RowOverSelected';" onMouseOut="this.className='RowOverOdd';"><td nowrap><a href="main.php?techtype=C" target="timedata">C</a></td></tr> <tr class="RowOverOdd" onMouseOver="this.className='RowOverSelected';" onMouseOut="this.className='RowOverOdd';"><td nowrap><a href="main.php?techtype=SM" target="timedata">SM</a></td></tr> <tr class="RowOverOdd" onMouseOver="this.className='RowOverSelected';" onMouseOut="this.className='RowOverOdd';"><td nowrap><a href="main.php?techtype=G" target="timedata">G</a></td></tr> <tr class="RowOverOdd" onMouseOver="this.className='RowOverSelected';" onMouseOut="this.className='RowOverOdd';"><td nowrap><a href="main.php?techtype=V" target="timedata">V</a></td></tr> <tr class="RowOverOdd" onMouseOver="this.className='RowOverSelected';" onMouseOut="this.className='RowOverOdd';"><td nowrap></td></tr> </table> </td> <td VALIGN="top" ALIGN="left"> <iframe ID="timedata" NAME="timedata" WIDTH="98%" FRAMEBORDER="0" src="dt_main.php"></iframe> </td> </tr> </table> </body> </html> ...................main.php.................... <?php session_start(); $theman = "Admin"; $staff = "Staff"; $userid = $_SESSION['valid_user']; $fname = $_SESSION['firstName']; $lname = $_SESSION['lastName']; $stat = $_SESSION['status']; $nowDate = date('Y-m-d H:i:s'); if(!isset($userid)){ header('Location: login_new.php'); } require_once('Connections/dt_db.php'); if(isset($_GET['techtype']) && $_GET['techtype'] != '') { $techtype = 'where Tech = \''.$_GET['techtype'].'\' '; $techtypesrch = 'Tech ="'.$_POST['techtype'].'" AND'; $techtypetxt = $_GET['techtype']; } else{ if(isset($_POST['techtype']) && $_POST['techtype'] != '') { $techtype = 'where Tech ="'.$_POST['techtype'].'" AND Approved="AP"'; $techtypesrch = 'Tech ="'.$_POST['techtype'].'" AND'; $techtypetxt = $_POST['techtype']; } else{ $techtype = ''; } } mysql_select_db($database_DT, $DTDB); $query_DTNode = "SELECT Node, Approved FROM TECH ".$techtype." group by Node"; $DTNode = mysql_query($query_DTNode, $DTDB) or die(mysql_error()); $row_DTNode = mysql_fetch_assoc($DTNode); $totalRows_DTNode = mysql_num_rows($DTNode); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <html> <head> <script language="javascript1.2" src="JScripts/toggle.js"></script> <script language="javascript" type="text/javascript"> function confirmation() { var agree=confirm("Delete this entry ?"); if (agree) return true ; else return false ; } </script> <link HREF="CSS/dt_css.css" REL="stylesheet" TYPE="text/css"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Decision Tree</title> </head> <body class="main"> <table width="99%"> <tr class="buttonright" width="100%"> <td width="2%">ID</td> <td width="50%" align="Left">Title</td> <td width="15%" align="Left">Creator</td> <td width="15%" align="Left">Owner</td> <td width="20" align="center">Cmds</td> <td width="15" align="center">Edit</td> </tr> </table> <?php do{ $Nodes = $row_DTNode['Node']; $query_DT = "SELECT * FROM `TECH` where Node='".$Nodes."' order by Priority desc"; $DT = mysql_query($query_DT, $DTDB) or die(mysql_error()); $row_DT = mysql_fetch_assoc($DT); $totalRows_DT = mysql_num_rows($DT); if($totalRows_DT > 0){ if(isset($_GET['selnode']) && $_GET['selnode'] == $row_DTNode['Node']){ $selnode1 = 'show'; $selnodeplus = '-'; } else{ $selnode1 = 'hide'; $selnodeplus = '+'; } echo '<table class="test" width="99%">'; echo '<tr class="nav" width="100%">'; echo '<th class="nav" width="5">'; echo '<table class="plusme">'; echo '<tr>'; echo '<td class="plusme" align="left">'; echo '<a class="plusminus" href="javascript:toggle(\'dt_'.$row_DTNode['Node'].'\', \''.$row_DTNode['Node'].'2\');">'; echo '<span id="'.$row_DTNode['Node'].'2">'.$selnodeplus.'</span></a>'; echo '</td>'; echo '</tr>'; echo '</table>'; echo '</th>'; if($row_DT['Approved'] != 'AP'){ echo '<th colspan="9" align="left" class="nav"><font color="red">'.$Nodes.' ('.$totalRows_DT.') </font></th> '; } else{ echo '<th colspan="9" align="left" class="nav">'.$Nodes.' ('.$totalRows_DT.')</th> '; } echo '</tr>'; echo '<tbody class="'.$selnode1.'" name="dt_'.$row_DTNode['Node'].'" id="dt_'.$row_DTNode['Node'].'" width="100%">'; do { $sqlLog = "SELECT * FROM `log` where logid='".$row_DT['id']."'"; $logqry = mysql_query($sqlLog, $DTDB) or die(mysql_error()); $logrow = mysql_fetch_assoc($logqry); $totalRows_a = mysql_num_rows($logqry); $d9 = strtotime('-90 days',time()); $datetimez = $logrow['timestamp']; $datetime = strtotime($datetimez); echo '<span onclick="window.location.href=\'dt_display.php?id='.$row_DT['id'].'\'"><tr class="test colLabel RowOverOdd" onmouseover="this.className=\'RowOverSelected\';" onmouseout="this.className=\'RowOverOdd\';" width="100%">'; echo '<td width="2%" nowrap>'.$row_DT['id'].'</td>'; if($row_DT['Approved'] != 'AP'){ echo '<td width="50%" align="left" nowrap><a href="dt_display.php?id='.$row_DT['id'].'"><font color="red"><strong>'.$row_DT['Title'].' ('.$totalRows_a.') </strong></font></td>'; } elseif($datetime < $d9){ echo '<td width="50%" align="left" nowrap><a href="dt_display.php?id='.$row_DT['id'].'"><font color="orange"><strong>'.$row_DT['Title'].' ('.$totalRows_a.')</strong></font></td>'; } else{ echo '<td width="50%" align="left" nowrap><a href="dt_display.php?id='.$row_DT['id'].'"><strong>'.$row_DT['Title'].' ('.$totalRows_a.')</strong></font></td>'; } echo '<td width="15%" align="left" nowrap>'.$row_DT['Creator'].'</td>'; echo '<td width="15%" align="left" nowrap>'.$row_DT['Modifier'].'</td>'; echo '<td width="15" align="center" nowrap><a href="dt_cmdswndw.php?cmdid='.$row_DT['id'].'"><img src="images/cmds.jpg" border="0" /></a></td>'; echo '<td width="15" align="center" nowrap><a href="dt_inputform.php?id='.$row_DT['id'].'"><img src="images/button_edit.png" border="0" /></td>'; if($stat === $theman){ echo '<td width="15" align="center" nowrap><a onclick="return confirmation()" href="dt_delete.php?id='.$row_DT['id'].'"><img src="images/b_drop.png" border="0" /></td>'; } echo '</tr></span><tr></tr>'; }while($row_DT = mysql_fetch_assoc($DT)); echo '</tbody>'; echo '</table>'; } }while ($row_DTNode = mysql_fetch_array($DTNode)) ; ?> </body> </html> .................. display.php ............................ <?php session_start(); require_once('Connections/dt_db.php'); $userid = $_SESSION['valid_user']; $stat = $_SESSION['status']; $submitDate = date('Y-m-d H:i:s'); $id = $_GET['id']; mysql_select_db($database_DT, $DTDB); $q = "insert into log (id, logid, userid, timestamp) VALUES ('','$id', '$userid', '$submitDate')"; mysql_query($q, $DTDB) or die (mysql_error()); echo '<br />'; echo $id; ?> Added code tags ~ CV Quote Link to comment Share on other sites More sharing options...
.josh Posted June 26, 2008 Share Posted June 26, 2008 okay maybe I'm just being stupid and these are unrelated, but: echo '<span onclick="window.location.href=\'dt_display.php?id='.$row_DT['id'].'\'"><tr class="test colLabel RowOverOdd" onmouseover="this.className=\'RowOverSelected\';" onmouseout="this.className=\'RowOverOdd\';" width="100%">'; echo '<td width="2%" nowrap>'.$row_DT['id'].'</td>'; if($row_DT['Approved'] != 'AP'){ echo '<td width="50%" align="left" nowrap><a href="dt_display.php?id='.$row_DT['id'].'"><font color="red"><strong>'.$row_DT['Title'].' ('.$totalRows_a.') </strong></font></td>'; } elseif($datetime < $d9){ echo '<td width="50%" align="left" nowrap><a href="dt_display.php?id='.$row_DT['id'].'"><font color="orange"><strong>'.$row_DT['Title'].' ('.$totalRows_a.')</strong></font></td>'; } else{ echo '<td width="50%" align="left" nowrap><a href="dt_display.php?id='.$row_DT['id'].'"><strong>'.$row_DT['Title'].' ('.$totalRows_a.')</strong></font></td>'; } In that first code block you have an onclick in the span that calls your display.php (which inserts) and the rest of your code blocks have links that also request display.php so maybe just maybe (I don't really know jack about js, so I'm just kinda pulling shit out my ass...) when you click on one of those links, since it's inside your span tag, it's triggering the onclick as well, causing it to be executed twice? Quote Link to comment Share on other sites More sharing options...
damerit Posted June 26, 2008 Author Share Posted June 26, 2008 That was it! The simple things in life can be the things that are hardest to overcome..... Thank you guys, I can move on now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.