# IP Address If/Then Help

**URL:** <https://forum.kirupa.com/t/ip-address-if-then-help/99831>\
**Category:** Uncategorized\
**Created:** [January 22, 2004, 6:29pm UTC](https://forum.kirupa.com/t/ip-address-if-then-help/99831 "2004-01-22T18:29:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yeldarb](https://avatars.discourse-cdn.com/v4/letter/y/51bf81/32.png) [@Yeldarb](https://forum.kirupa.com/u/Yeldarb)\
**Post date:** [January 22, 2004, 6:29pm UTC](https://forum.kirupa.com/t/ip-address-if-then-help/99831/1 "2004-01-22T18:29:29Z")

</div>

I have been trying to get this all morning, I’ve checked the PHP manual, done some googling and haven’t been able to solve the problem. Here’s what I want to do. I want to have it so that I can “ban” a particular IP address, but instead of not allowing them access, give them a login page instead. Then, only people who have the password can log on from that IP.

```php

<?php

$bannedIP = 205.221.223.32;
$yourIP = $_SERVER['REMOTE_ADDR'];
$enteredPass = HTTP_POST_VARS['password'];
$thePassword = password;

if($bannedIP == $yourIP && enteredPass != $thePassword) {
	echo "<html>
<body>
";
	echo "You Must Enter a Password.<br>
";
	echo "<form action="index.php">
 <b>Password:</b> <input type="text" name="password"><br>
 <input type="submit"" name="Submit">

";
	echo "</body>
</html>";
else {

```

Any help would be greatly appreciated, thanks 🙂

Oh and btw, after the else is the code for the main page that should be accessed if they either have the password or are coming from a different IP

EDIT: The newlines don’t seem to show up, but that’s what those random n’s scattered about are, escaped n’s (  
)
