Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6707499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:38:49+00:00 2026-05-26T07:38:49+00:00

I’m using sessions to receive my info from my database table… But I’m not

  • 0

I’m using sessions to receive my info from my database table… But I’m not quite sure how to get a image because if I just say this

echo '$_SESSION[pic_location]';

I don’t know if one could use the img tag in a certain way or not…

it gives me a string of the image’s path and not the image itself. How can I solve this matter?

Here is my picUpload.php document

<?php
             include 'connect.php';
             include 'header.php';

             if(isset($_SESSION['signed_in']) && $_SESSION['signed_in'] == true)
            {
                 //This is the directory where images will be saved 
                 $target=$_SERVER['DOCUMENT_ROOT'] . "/avatars/" . basename( $_FILES['file']['name']); 

                 //$target = "avatars/"; 
                //$target = $target . basename( $_FILES['file']['name']); 

                 //This gets all the other information from the form 
                 $pic_location=($_FILES['file']['name']); 

                 //Writes the information to the database
                 $sql = "UPDATE users SET pic_location='$target' WHERE user_id=" . $_SESSION['user_id'];
                 $result = mysql_query($sql);

                 if(!$result)
                {
                    //something went wrong, display the error
                    echo "Sorry, there was a problem uploading your file.";
                    //echo mysql_error(); //debugging purposes, uncomment when needed
                }
                else
                {
                    //Writes the photo to the server 
                    if(move_uploaded_file($_FILES['file']['tmp_name'], $target))
                    {
                        //Tells you if its all ok 
                        echo "The file ". basename( $_FILES['file']['name']). " has been uploaded, and your information has been added to the directory"; 
                    } 
                    else
                    {
                    //nothing
                    }
                }
            }
?> 

and my profile.php where I want to display the image

<?php
        include 'connect.php';
        include 'header.php';

            //

            if(isset($_SESSION['signed_in']) == false || isset($_SESSION['user_level']) != 1 )
                {
                    //the user is not an admin
                    echo '<br/>';
                    echo 'Sorry! You have to be <a href="/signin.php"><b>logged in</b></a> to view your profile <a href="signup.php" title="Become a registered user!"></a>.';
                    echo '<br/><br/>';
                }
                else
                {
                    echo '<h2>Profile of </h2>'.$_SESSION['user_name'];
                    echo '<h2>Info about you: </h2>';

                    //user_pass = '" . mysql_real_escape_string($_POST['user_pass']) . "'";

                    $explodedPath = explode("C:/xampp/htdocs/avatars" , $_SESSION['pic_location']);
                    echo '<img src="http://[localhost]'.$explodedPath[1].'" />';

                    echo '<br/><br/>';
                    echo '<b>Logged in as: </b>'.$_SESSION['user_name'];    echo'<pp><a href="#" title="Change your user name">edit</a></pp>';
                    echo '<br/><br/>';
                    echo '<b>Your email address: </b>'.$_SESSION['user_email']; echo'<pp><a href="#" title="Change your email address">edit</a></pp>';
                    echo '<br/><br/>';
                    echo '<b>Your user level: </b>'.$_SESSION['user_level'].'   (1 = admin AND 0 = user)';
                    echo '<br/><br/>';
                    echo '<b>Your friends: </b> // FRIENDS';

                    //echo 'Welcome, ' . $_SESSION['user_name'] . '! <br /><br/><br/><a href="index.php"><b>Proceed to the link sharing</b></a>.';
                    ///////////////////////////////
                    /// adding users as friends ///
                    ///////////////////////////////

                    //while($user = mysql_fetch_array($result))
                    //echo $user['user_name'].' 
                        //<a href="addfriend.php?user='.$user['id'].'">ADD TO FRIENDS</a><br/>';
                    echo '<br/><br/>';
                    echo '<br/><br/>';
                    echo '<b>Do you want to upload or change your profile picture?</b>';
                    echo '<br/><br/>';
                    echo '<form action="picUpload.php" method="post" enctype="multipart/form-data">
                            <label for="file">Filename: </label>
                            <input type="file" name="file" id="file"/>      
                            <br/><br/>
                            <input type="submit" name="submit" value="Upload" />
                         </form>';

                    //NOW I WANT TO MAKE A SPECIFIC "ADD AS FRIEND" LINK NEXT TO EACH USER


                }
                include 'footer.php';
?>

Thank you!

🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:38:50+00:00Added an answer on May 26, 2026 at 7:38 am

    Try this

    <?php echo '<img src="$_SESSION[pic_location]"; /> ?> 
    //Considering $_SESSION[pic_location] giving you the full image path
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.