这是我迄今为止注册用户的代码。
现在我需要:
- 如果用户名已被占用,则返回错误消息
- 如果字段为空,则显示错误消息
这是代码:
//=============Configuring Server and Database=======
$host = 'localhost';
$user = 'root';
$password = 'revilo';
//=============Data Base Information=================
$database = 'dbsneaker';
$conn = mysql_connect($host,$user,$password) or die('Server Information is not Correct'); //Establish Connection with Server
mysql_select_db($database,$conn) or die('Database Information is not correct');
//===============End Server Configuration============
//=============Starting Registration Script==========
$userName = mysql_real_escape_string($_POST['txtUser']);
$password = mysql_real_escape_string($_POST['txtPassword']);
if(isset($_POST['btnRegister'])) //===When I will Set the Button to 1 or Press Button to register
{
$query = "insert into bladmin(admin_usr_name, admin_pwd) values('$userName', '$password')";
$res = mysql_query($query);
header('location:success_register.php');
}
任何帮助,将不胜感激