What's new

Pano ko sya madadala

loktoy

Eternal Poster
Joined
Oct 20, 2014
Posts
1,168
Solutions
2
Reaction
103
Points
497
Age
30
ito kasi $file_path ay nasa signup.php
ito code ko :

if ($uploadOk == 1) {
if (move_uploaded_file($source_path, $destination_path)) {
$file_path = mysqli_real_escape_string($con, $destination_path);

$query = "INSERT INTO registration (payee_name, email_address, username, password, user_type, image) VALUES ('$payee_name', '$email_address', '$username', '$password', '2', '$file_path')";
$result = mysqli_query($con, $query);
echo "<div class='alert alert-success' role='alert'>
A simple success alert—check it out!
</div>";

echo "<img src='$file_path' alt='Uploaded Image' width='200'>"; // Add this line
}

ngayon gusto ko mangyari is magagamit ko sa kabila page na navbar.php yun $file_path gusto ko mangyari ay pwede ko sya eecho sa navbar.php..
ito code ko

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'];
$picture = $row_edit['image'];

}
}
 
To use the $file_path variable in the navbar.php file, you can do the following:

1. In the signup.php file, store the $file_path value in a session variable:
PHP:
$_SESSION['file_path'] = $file_path;

2. In the navbar.php file, retrieve the value of $file_path from the session:
PHP:
if (isset($_SESSION['file_path'])) {
    $file_path = $_SESSION['file_path'];
    // Now you can use the $file_path variable here
} else {
    // Handle the case when $file_path is not set in the session
}

You can then echo the $file_path value in the navbar.php file wherever you want, using the following code:
PHP:
echo $file_path;

Note: Make sure you start the session at the beginning of both signup.php and navbar.php files by adding session_start(); at the top of each file.
 

Similar threads

Back
Top