我需要检查用户名是否被使用,如果是,它不会允许用户注册,它会将他们重定向到注册页面我应该在哪里添加脚本来检查用户名是否已经被使用?或者我在哪里可以得到一个脚本继承我的脚本我到目前为止。
<?php
// Check if he wants to register:
if (!empty($_POST[username]))
{
// Check if passwords match.
if ($_POST[password] != $_POST[password2])
exit("Error - Passwords don't match. Please go back and try again.");
// Assign some variables.
$date = time (" d - m - Y ");
$ip = $_SERVER[REMOTE_ADDR];
require_once("connect.php");
// Register him.
$query = mysql_query("INSERT INTO members
(username, fname, email, password, date, ip)
VALUES ('$_POST[username]','$_POST[fname]','$_POST[email]','$_POST[password]','$date','$ip')")
or die ("Error - Couldn't register user.");
echo "Welcome $_POST[username]! You've been successfully reigstered!<br />
You Will Be Redirected To Our Home Page Where U Can Login ";
exit();
}
?>