habe so aus langeweile n register in php und mysql programmiert viel spass xd
PHP
<?php
mysql_connect("localhost", "root", "root") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());
if(!empty($_POST['login'])) {
if(empty($_POST['username']) || empty($_POST['password'])) {
echo "Bitte fülle alle Felder aus!";
} else {
$username = mysql_real_escape_string($_POST['username']);
$rows = mysql_query("SELECT FROM users WHERE username = '$username' ") or die(mysql_error());
if(mysql_num_rows($rows) > 1) {
echo "Der Username wurde bereits registiert!";
} elseif(!ctype_alnum($_POST['username'])) {
echo "Dieser Username ist ungültig!";
} elseif(strlen($_POST['username']) > 12) {
echo "Der Username ist zu lang!";
} else {
$password = sha1($_POST['password']);
mysql_query("INSERT INTO `users` (`username`, `password`) VALUES ('$username', '$password') ") or die(mysql_error());
}
}
}
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF8" />
<title></title>
</head>
<body>
<form action="" method="POST">
<input type="text" name="username" placeholder="Username" required/>
<input type="password" name="password" placeholder="Passwort" required/>
<input type="submit" name="login" value="Registieren" />
</form>
</body>
</html>
Alles anzeigen