Unique user
This commit is contained in:
parent
30f7df439e
commit
f3bc8ecd9d
@ -52,6 +52,7 @@ else{
|
||||
</nav>
|
||||
<form method="post" action="insert.php" ENCTYPE="multipart/form-data">
|
||||
<div class="addPostForm">
|
||||
<p>Tytul posta</p>
|
||||
<input type="text" name="title" size="120">
|
||||
<p>Meta opis</p>
|
||||
<input name="meta_desc" size="120">
|
||||
|
@ -7,11 +7,17 @@ if ($_SERVER['REQUEST_METHOD'] == "POST"){
|
||||
$email = $mysqli->real_escape_string($_POST['email']);
|
||||
$password = md5($_POST['password']);
|
||||
$avatar_path = $mysqli->real_escape_string('../images/avatars/'.$_FILES['avatar']['name']);
|
||||
|
||||
$checkUser = $mysqli->query("SELECT * FROM user WHERE username='$username'");
|
||||
if ($checkUser->num_rows === 1){
|
||||
$_SESSION['message'] = "Użytkownik o tej nazwie już istnieje";
|
||||
}
|
||||
else{
|
||||
if (preg_match("!image!", $_FILES['avatar']['type'])){
|
||||
if(copy($_FILES['avatar']['tmp_name'], $avatar_path)){
|
||||
$_SESSION['username'] = $username;
|
||||
$_SESSION['avatar'] = $avatar_path;
|
||||
|
||||
|
||||
$sql = "INSERT INTO user (username,email,password,avatar)"
|
||||
. "Values ('$username','$email','$password','$avatar_path')";
|
||||
|
||||
@ -24,16 +30,20 @@ if ($_SERVER['REQUEST_METHOD'] == "POST"){
|
||||
}
|
||||
}
|
||||
else{
|
||||
$_SESION['message'] = "Nie udało się dodać pliku!"; }
|
||||
$_SESION['message'] = "Nie udało się dodać pliku!";
|
||||
}
|
||||
}
|
||||
else{
|
||||
$_SESSION['message'] = "Dostępne typy plików to JPG, PNG, GIF";
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
$_SESSION['message'] = "Hasła nie są identyczne!";
|
||||
}
|
||||
}
|
||||
echo $_SESSION['message'];
|
||||
|
||||
|
||||
?>
|
||||
?>
|
||||
<p></p>
|
||||
<a href="index.php">Powrót do rejestracji </a>
|
Loading…
Reference in New Issue
Block a user