Phc robot pahelp sa display

loktoy

Established
di lumalabas yun picture sa navbar ko gusto ko sana pagkaregistered ko at mag lologin ako lalabas sa navbar ko yun picture na inupload ko sa signup.php

ito code ko sa signup.php

$target_dir = "./photo_folder/";
$target_file = $target_dir . basename($_FILES["profile-pic"]["name"]);
$uploadOk = 1;
if ($uploadOk == 1) {
if (move_uploaded_file($_FILES["profile-pic"]["tmp_name"], $target_file)) {
$file_path = mysqli_real_escape_string($con, $target_file);

$query = "INSERT INTO registration (payee_name, email_address, username, password, user_type, img) VALUES ('$payee_name', '$email_address', '$username', '$password', '2', '$file_path')";
$result = mysqli_query($con, $query);

ito naman code ko sa navbar.php

<?php
session_start();
include "../config/config.php";
if(isset($_SESSION['user_id'])){
$user_id = $_SESSION['user_id'];
$_GET_RECORD = mysqli_query($con,"SELECT * FROM registration WHERE user_id = '$user_id' ");
while($row_edit = mysqli_fetch_assoc($_GET_RECORD)) {
$user_id = $row_edit['user_id'];
$payee_name = $row_edit['payee_name'];
$email_address = $row_edit['email_address'];
$username = $row_edit['username'];
$password = $row_edit['password'];
$file_path = $row_edit ['img'];

}
}else {
echo "You must login first! <a href = '../login.php'>Login now! </a>";
}

?>

<img src="./photo_folder/<?php echo $row_edit['img']; ?>">
 
Based on the code you provided, it seems that you are storing the file path of the uploaded image in the img column of your registration table. To display the image in your navbar, you can use the <img> tag and set the src attribute to the file path stored in the $file_path variable.

However, there are a few issues with your code that might be preventing the image from displaying correctly. Here are some suggestions to troubleshoot the issue:

1. Check the file path: Make sure that the file path stored in the img column is correct and matches the actual location of the uploaded image. You can verify this by checking the value stored in the img column in your database.

2. Check the file permissions: Ensure that the permissions of the photo_folder directory and the uploaded image file are set correctly so that the web server can access and display the image. You can try setting the directory permissions to 755 and the file permissions to 644.

3. Verify the database query: Double-check that the database query is successfully inserting the file path into the img column. You can check this by running the query directly in your database or by adding some debugging statements to your code.

4. Check the session data: Make sure that the session data is being set correctly after the user logs in. You can add some debugging statements to check if the $_SESSION['user_id'] is being set and if the query is retrieving the correct user information.

If you have already checked all these aspects and the image is still not displaying, please provide any error messages or additional relevant code that might help in diagnosing the issue.
 

About this Thread

  • 1
    Replies
  • 330
    Views
  • 1
    Participants
Last reply from:
Unknown user

Online now

Members online
994
Guests online
1,080
Total visitors
2,074

Forum statistics

Threads
2,276,161
Posts
28,967,972
Members
1,231,145
Latest member
kennethCASTRO2012
Back
Top