Jump to content

Two curious problems I'm having with this script


BadGoat

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.