<?php
$host = "127.0.0.1";
$user = "root";
$passwd = "1234";
$dbname = "fuckchat";
mysql_connect($host,$user,$passwd) or die("Can not connect to the server");
mysql_select_db($dbname) or die("Can not connect to the database");
$sql="insert into `fuckuser` (`username`,`password`,`name`)
values('$username','$password','$name')";
mysql_query("set NAMES UTF8");
$sqlquery=mysql_db_query($dbname, $sql);
$checkadd = "select*from `fuckuser` where username='$username'";
$result = mysql_db_query($dbname, $checkadd);
$num=mysql_num_rows($result);
if ($num==1)
{
print"<br>Your name has been successfully added";
}elseif($num>=1)
{
print"<br>Your name has already been used ";
}else
{
print"Error!!!";
};
mysql_close();
?>
<?php
$host = "127.0.0.1";
$user = "root";
$passwd = "1234";
$dbname = "fuckchat";
mysql_connect($host, $user, $passwd) or die("Can not connect to the server");
mysql_select_db($dbname) or die("Can not connect to the database");
mysql_query("set NAMES UTF8");
$checkadd = " SELECT * FROM 'fuckuser' WHERE username = '".$username."' ";
$result = mysql_db_query($dbname, $checkadd) or die (mysql_error());
$num = mysql_num_rows($result);
if($num<=0){
$sql=" INSERT INTO fuckuser ('username', 'password', 'name') ";
$sql.=" VALUES ";
$sql.=" ('".$username."', '".$password."', '".$name."') ";
$qr = mysql_db_query($dbname, $sql) or die (mysql_error());
print"<br>Your name has been successfully added";
}else{
print"<br>Your name has already been used ";
};
mysql_close();
?>