Jump to content

Recommended Posts

I'm using this script to redirect for site maintenance.

 

<?php
$hostname="localhost"; 
$username="xxxxxx"; 
$password="xxxxxx"; 
$database="xxxxxx";
$tbl_name="xxxxxx";

// Connect to the database 
MYSQL_CONNECT($hostname, $username, $password) OR DIE("Unable to connect"); 
MYSQL_SELECT_DB("$database") OR DIE("Unable to select database");

$result = mysql_query("SELECT * FROM $tbl_name") 
or die(mysql_error());  

while($row = mysql_fetch_array( $result )) {
$maint_on_off = $row['on_off'];
}

if ($maint_on_off == "1") {
	header ('Location: ../maintenance.php');
}
?>

 

 

Does anyone know how I can redirect everyone except myself. Maybe using IP to detect.

Link to comment
https://forums.phpfreaks.com/topic/203232-redirect-all-be-me/
Share on other sites

Test $_SERVER['HTTP_REMOTE_ADDR']

 

Not what I was looking for.

 

I need something like

<?php

if ('My IP Adress") {
do not redirect
} else (Any other IP){
redirect 
};

?>

 

 

I just don't know how to implement that into my current code

 

Um ... I think it is

 

if ($_SERVER['REMOTE_ADDR'] == '123.456.789') {
do not redirect
} else {
redirect 
};

 

(I actually typed the variable wrong the first time, it should be just 'REMOTE_ADDR')

Link to comment
https://forums.phpfreaks.com/topic/203232-redirect-all-be-me/#findComment-1064808
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.