Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP]Problem z update profileimg do bazy danych
marsoonn
post 28.12.2020, 15:42:46
Post #1





Grupa: Zarejestrowani
Postów: 22
Pomógł: 0
Dołączył: 18.12.2020

Ostrzeżenie: (0%)
-----


Hey, mam problem z updatem profileimg do bazy danych,
Jest sprawdzone czy user jest zalogowany tylko tego nie wstawiam,
Chodzi o to że po update zdjęcia profilowego w bazie danych nic sie nie zmienia
kolumna którą chciałbym aby zawierało zdjęcie to "profileimg" jest to MEDIUM BLOB

DB tabela "users":
https://imgur.com/a/MSlEOE4

Kod

updateimg.php
  1. <?php
  2. require "../header.php";
  3. ?>
  4.  
  5. <form action="../includes/update.inc.php" method="post" enctype='multipart/form-data'>
  6. <input type="file" name="file">
  7. <button type='submit' name='submit' style='max-width: 100px;'>Prześlij</button>
  8. </form>



update.inc.php
  1. <?php
  2. if(isset($_POST['submit'])) {
  3. require 'dbh.inc.php';
  4.  
  5. $img = $_POST['file'];
  6. $id = $_SESSION["userid"];
  7. echo $img;
  8.  
  9. $update3 = "UPDATE users SET profileimg = '$img' WHERE usersId = '$id'";
  10. $run3 = mysqli_query($conn, $update3);
  11.  
  12. //$_SESSION["usersName"] = $_POST['name'];
  13.  
  14. if($run3){
  15. header("Location: ../profil.php");
  16. }
  17. else
  18. {echo "Błędne dane proszę spróbuj ponownie";}
  19. }
  20. ?>


PROSZĘ O POMOC BĘDĘ MEGA WDZIĘCZNY
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
viking
post 28.12.2020, 15:53:25
Post #2





Grupa: Zarejestrowani
Postów: 6 378
Pomógł: 1116
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


Poczytaj sobie przykłady https://www.php.net/manual/en/function.move...loaded-file.php


--------------------
Go to the top of the page
+Quote Post
marsoonn
post 28.12.2020, 17:09:11
Post #3





Grupa: Zarejestrowani
Postów: 22
Pomógł: 0
Dołączył: 18.12.2020

Ostrzeżenie: (0%)
-----


Cytat(viking @ 28.12.2020, 15:53:25 ) *


No dobra a takie pytanko

move_uploaded_file($_FILES['file']['tmp_name'], $move);

jak zapisać prawidłowo wartość X dla

$id = $_SESSION["userid"];
$move = X; questionmark.gif

Chciałbym aby to X to była baza danych tabela "users" kolumna "profile" WHERE usersId = "$id"
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 21.06.2025 - 23:28