I have a very simple PHP page. When someone loads the page it logs their IP and date in an SQL Server and a message appears “IP NOT registered”.

If the same user loads the page again (now there IP and Date is stored in the sql) the user message is “IP address registered”.

this is my code… please help… NOTE: SQL setup and running.

<?php //SQL CONNECT $host="xxx"; // Host name $user="xxx"; // Mysql username $pw="xxx"; // Mysql password $db="xxx"; // Database name $tbl="xxx"; // Table name //SQL CONNECT //GET VARIABLES $ip = $_SERVER['REMOTE_ADDR'];// Get IP Address $date = date("Ymd");// Get IP Address //GET VARIABLES echo $ip; // shows IP Address echo $date; // shows date // Connect to server and select databse. $pfw_link = mysql_connect($host, $user, $pw); if (!$pfw_link) { die('Could not connect: ' . mysql_error()); } $pfw_db_selected = mysql_select_db($db, $pfw_link); if (!$pfw_db_selected) { die ('Can not use $db : ' . mysql_error()); } $select="SELECT * FROM $tbl WHERE ip='$ip' and date='$date'"; $insert ="INSERT INTO `REGISTERED_USERS`(`ip`,`date`)VALUES (\"$ip\",\"$date\")" ; $result=mysql_query($select); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==0){ $insert; echo ("IP NOT registered"); } else if($count==1){ // Register $myusername, $mypassword and redirect to file "members.php" echo ("IP address registered"); } ?>

what is your question??

Sponsor our Newsletter | Privacy Policy | Terms of Service