Unique user
This commit is contained in:
parent
30f7df439e
commit
f3bc8ecd9d
@ -52,6 +52,7 @@ else{
|
|||||||
</nav>
|
</nav>
|
||||||
<form method="post" action="insert.php" ENCTYPE="multipart/form-data">
|
<form method="post" action="insert.php" ENCTYPE="multipart/form-data">
|
||||||
<div class="addPostForm">
|
<div class="addPostForm">
|
||||||
|
<p>Tytul posta</p>
|
||||||
<input type="text" name="title" size="120">
|
<input type="text" name="title" size="120">
|
||||||
<p>Meta opis</p>
|
<p>Meta opis</p>
|
||||||
<input name="meta_desc" size="120">
|
<input name="meta_desc" size="120">
|
||||||
|
@ -7,11 +7,17 @@ if ($_SERVER['REQUEST_METHOD'] == "POST"){
|
|||||||
$email = $mysqli->real_escape_string($_POST['email']);
|
$email = $mysqli->real_escape_string($_POST['email']);
|
||||||
$password = md5($_POST['password']);
|
$password = md5($_POST['password']);
|
||||||
$avatar_path = $mysqli->real_escape_string('../images/avatars/'.$_FILES['avatar']['name']);
|
$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 (preg_match("!image!", $_FILES['avatar']['type'])){
|
||||||
if(copy($_FILES['avatar']['tmp_name'], $avatar_path)){
|
if(copy($_FILES['avatar']['tmp_name'], $avatar_path)){
|
||||||
$_SESSION['username'] = $username;
|
$_SESSION['username'] = $username;
|
||||||
$_SESSION['avatar'] = $avatar_path;
|
$_SESSION['avatar'] = $avatar_path;
|
||||||
|
|
||||||
|
|
||||||
$sql = "INSERT INTO user (username,email,password,avatar)"
|
$sql = "INSERT INTO user (username,email,password,avatar)"
|
||||||
. "Values ('$username','$email','$password','$avatar_path')";
|
. "Values ('$username','$email','$password','$avatar_path')";
|
||||||
|
|
||||||
@ -24,16 +30,20 @@ if ($_SERVER['REQUEST_METHOD'] == "POST"){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$_SESION['message'] = "Nie udało się dodać pliku!"; }
|
$_SESION['message'] = "Nie udało się dodać pliku!";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$_SESSION['message'] = "Dostępne typy plików to JPG, PNG, GIF";
|
$_SESSION['message'] = "Dostępne typy plików to JPG, PNG, GIF";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else{
|
else{
|
||||||
$_SESSION['message'] = "Hasła nie są identyczne!";
|
$_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