<?php//make a MySQL connectioninclude('config.php');//create a MySQL table in the selected databasemysql_query("CREATE TABLE `page` ( `ipid` int(11) NOT NULL auto_increment, `ip` varchar(20) NOT NULL, `text` text collate utf8_unicode_ci, PRIMARY KEY (`ipid`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1")or die(mysql_error());?>
<?php //MySQL Configuration//DB Host (Normally 'localhost')$dbhost = 'localhost';//DB Database Username$dbusername = 'root';//DB Database User Password$dbpassword = 'mypassword';//DB Database Name$dbname = 'dbname';//mysql_connect function$conn=mysql_connect($dbhost, $dbusername, $dbpassword);if(!$conn) : die('Could not connect: ' . mysql_error());endif;$db=mysql_select_db($dbname, $conn);if(!$db) : die ('Cant connect to database : ' . mysql_error());endif;?>
<title>Insert Page</title><center><h2>INSERT PAGE</h2></center><BR><?php//make a MySQL connectioninclude('config.php');//to check if a submit button was clicked, use this...if(isset($_POST['submit'])){$text = $_POST['text'];$ip = $_POST['ip'];//the INSERT INTO statement is used //to add new records to a database tablemysql_query("INSERT INTO page (text,ip)VALUES ('$text','$ip')")or die(mysql_error()); }else{$ip = $_SERVER['REMOTE_ADDR'];echo "My IP = " . $ip . "<br>";?><form method="post" action="insert.php"><TABLE><TR><TD>Text: </TD><TD><input name="text" value="Sorry Guest, you are banned from using this website!" size="60" maxlength="255"></TD></TR><TR><TD>IP:</TD><TD><input name="ip" size="60" maxlength="255"></TD></TR><TR><TD><input type="submit" name="submit" value="submit"></TD></TR></TABLE></form><?php}?>
<?php////make a MySQL connectioninclude('config.php');//get ip$ip = $_SERVER['REMOTE_ADDR'];//get ip, text, linkurl from the page table//..or..*=select everything from the table page$result = mysql_query("SELECT ip, textFROM page")or die(mysql_error()); while($myrow = mysql_fetch_assoc($result)) {if($myrow['ip']==$ip){echo "<center><h2>$myrow[text]</h2></center>";die();}}?>Web Page Code