Hi
I'm a beginner with PHP and MySQL and would like to add a function to a website that lets registered users upload an avatar picture of themselves and store the path in MySQL.
Then have a page which displays back the correct image for whoever is logged in.
I created 2 mySQL tables, users & images
Users table fields - username (is PK), name, password
images table fields - imageID (is PK), username (is FK) and imagePath.
I run through online tutorials and have got an image upload working but i have problems
1. if I upload 2 images with the same name i get an error so i think i need to rename each image to a random filename.
2. displaying conect from the database for member currently logged in, both text and image. the online tutorial i echo'd the image but just got the path.
If someone could explain how to write this code for this purpose, i use notepad++ i would very much like to learn php
thanks you
I'm a beginner with PHP and MySQL and would like to add a function to a website that lets registered users upload an avatar picture of themselves and store the path in MySQL.
Then have a page which displays back the correct image for whoever is logged in.
I created 2 mySQL tables, users & images
Users table fields - username (is PK), name, password
images table fields - imageID (is PK), username (is FK) and imagePath.
I run through online tutorials and have got an image upload working but i have problems
1. if I upload 2 images with the same name i get an error so i think i need to rename each image to a random filename.
2. displaying conect from the database for member currently logged in, both text and image. the online tutorial i echo'd the image but just got the path.
If someone could explain how to write this code for this purpose, i use notepad++ i would very much like to learn php
thanks you
Comment