When users signup for a site and have spaces, periods, or @ in the usernames it seems to create problems. How can I include these characters?
MySQL couldn't care less about characters in a username or password, unless you're not constructing your query properly:
$password = $_POST['password'];
$username = $_POST['username'];
$quoted_pass = mysql_real_escape_string($password);
$quoted_user = mysql_real_escape_string($username);
$sql = "INSERT INTO users (username, password) VALUES ('$quoted_pass', '$quoted_user');
$result = mysql_query($sql) or die(mysql_error());
if (mysql_affected_rows($result) != 1) {
die("User record not created");
}
精彩评论