Need help code wont work

[php]<?php
$con = mysql_connect(“localhost”,“user”,“pass”);
mysql_select_db(“db_name”, $con);
$ip=$_SERVER[‘REMOTE_ADDR’];
$query = mysql_query(“SELECT * FROM user_table WHERE ip = '”. $ip ."’");

if (mysql_num_rows($query) > 0)

{
echo ‘Hey Welcome back’;
}
{
mysql_query(“INSERT INTO welcome (ip)
VALUES (’”. $ip ."’)"); echo 'Hey ';
echo $ip;
echo ‘

This is the First time you Visited

’;
echo ‘Play Now Or Continue to the Site’;
}
mysql_close($con);
?>[/php]
can anyone help im new to php and this is on of my first script ive done on my own…

Well, you compare to see if it is a previously used IP address. First, this is the worst way to validate a user.
You should use a userID and password. I can log on using any of 500 computers I know of and can become a new user and wreak havoc on your site. Once in awhile the IP address is useful, but, seldom for validation.

Next, on the programming, you do an If()say"welcome back" and end there. Where is yours ELSE?
Should be something like
if(){
do this
}else{
do something else…
}
Hope that helps…

Sponsor our Newsletter | Privacy Policy | Terms of Service