fullyloaded Posted March 16, 2007 Share Posted March 16, 2007 hi any one know how to add a redirect to this little bit of script? its for banning ip's as of now it will only show this (You have been banned from viewing this website.) thanks <?php //place the users IP in the ip variable $ip = $_SERVER['REMOTE_ADDR']; $connection = mysql_connect("localhost", "****", "*****") or die(mysql_error()); mysql_select_db("****"); $query = mysql_query("SELECT * FROM banned_users WHERE userip='$ip'"); //check to see if the users IP matches a banned IP $select_banned = mysql_num_rows($query); if($select_banned == 1) { //print a message to the user if they are banned print "You have been banned from viewing this website."; //stop the page from being loaded exit; } ?> Link to comment https://forums.phpfreaks.com/topic/42942-solved-redirect/ Share on other sites More sharing options...
per1os Posted March 16, 2007 Share Posted March 16, 2007 <?php //place the users IP in the ip variable $ip = $_SERVER['REMOTE_ADDR']; $connection = mysql_connect("localhost", "****", "*****") or die(mysql_error()); mysql_select_db("****"); $query = mysql_query("SELECT * FROM banned_users WHERE userip='$ip'"); //check to see if the users IP matches a banned IP $select_banned = mysql_num_rows($query); if($select_banned == 1) { header('Location: http://www.sitetoredirecto.com'); //print a message to the user if they are banned //print "You have been banned from viewing this website."; //stop the page from being loaded exit; } ?> Is that what you are looking for? Link to comment https://forums.phpfreaks.com/topic/42942-solved-redirect/#findComment-208590 Share on other sites More sharing options...
fullyloaded Posted March 16, 2007 Author Share Posted March 16, 2007 hi thanks for the fast reply but it didnt work you think its because i have the include in the pages i want banned? Link to comment https://forums.phpfreaks.com/topic/42942-solved-redirect/#findComment-208594 Share on other sites More sharing options...
fert Posted March 16, 2007 Share Posted March 16, 2007 are you getting a header error? Link to comment https://forums.phpfreaks.com/topic/42942-solved-redirect/#findComment-208596 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.