BadGoat Posted December 5, 2006 Share Posted December 5, 2006 Hello!I've written a script which allows me to input an IP from our LAN, which would then display the user info using that IP. I've created a link so that when someone looks at the record, the action of clicking the link increments a counter by one. Problem #1: If I refresh the page which contains the code below, it increments again, which is something I wanted to prevent. Is there a way to disallow this, either by causing the page to forward to a different page after 3 seconds or something, or is there a better solution using PHP?Problem #2: The first time I look at an IP, the incrementation goes up by 3 rather than by 1. Any subsequent search on that IP will increment correctly, by 1. I've checked and checked again, and the MySQL db is defaulted to 0, so I am at a loss as to why it increments by 3 when the db entry is 0, and by 1 when the db entry is anything but 0. [code]<?$connect= mysql_connect("xxxxx", "xxxxx", "xxxxx") or die ("Could not connect to database!");$result= mysql_select_db("xxxxx") or die("Could not select that database !");echo'<td width="*%" valign="top" bgcolor="white"><table class="C1" align="center" height="100%" bgcolor="white"><tr> <td>'; //$id = $_REQUEST['id']; //$_GET['id'] = $id; $query5 = "UPDATE ipcount SET count = count+1 WHERE block_id='$id'" ; $result5 = mysql_query($query5) or die("<b>mySQL Error:</b>"); if(!$result5) { echo 'Error processing request.'; } else { echo '<B>Thank you</B>'; } echo'<tr><td><center> <form name="search" method="post" action="/ip_search.php"> <input type="text" name="find" /> <input type="hidden" name="searching" value="yes" /><br /><br /> <input type="submit" name="search" value="Find!" /> </form></center></td></tr></table><!-- END EMBEDDED CENTER TABLE --></td>'; ?>[/code] Link to comment https://forums.phpfreaks.com/topic/29570-two-curious-problems-im-having-with-this-script/ Share on other sites More sharing options...
artacus Posted December 5, 2006 Share Posted December 5, 2006 what is the default value for that field? Link to comment https://forums.phpfreaks.com/topic/29570-two-curious-problems-im-having-with-this-script/#findComment-135702 Share on other sites More sharing options...
BadGoat Posted December 5, 2006 Author Share Posted December 5, 2006 The default value I have set is zero. Link to comment https://forums.phpfreaks.com/topic/29570-two-curious-problems-im-having-with-this-script/#findComment-135708 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.