I am trying to write a script to block a certain troublesome user from viewing my webpage but especially from writing in my guestbook. I am a very new to PHP scripting and have been learning by modifying pre-written scripts. My guestbook uses a PHP script to access a MySQL database.

If anyone has a way to do this, I would appreciate the insight.

Thanks
Cathy

    I am assuming by IP address... but do you know his ip address?

      The php ip address collector is really not reliable, but it's $_SERVER['REMOTE_ADDR']

        Yes, I know his IP address from looking at my hit counter's statistics, which logs IP addresses.

          Yes...he's been on my site 165 times in the past few weeks and all with the same address.

            If you are ABSOLUTELY sure he always uses the same IP, do something like this :

            <?
            if($_SERVER["REMOTE_ADDR"] == "abc.def.ghi.jkl") {
                exit("Sorry, you're banned! Mouahahahahahahah!<BR/>\n");
            }
            ?>

            ... where abc.def.ghi.jkl is the IP address ...

            Also, place it at the top of the page(s).

              I tried the script and it seemed to work well when i put my IP in to test it; but when i changed the address to the one i want to ban, i am still banned...otherwise, that's exactly what I am looking for.

                Can you post the code you wrote?

                  here's what I used.

                  <?
                  if($_SERVER["REMOTE_ADDR"] == "208.13.105.120") {
                  exit("An internal error has prevented this page from loading. Please contact system administrator.<BR/>\n");
                  }
                  ?>

                  I put it right after the html title tag so that it would not display any of the page.

                  As I said, it started blocking everyone.

                    Write a Reply...