0

upload profile image but upload only ram user pic .other user not able to upload there image .how to define every user has upload there prof. image . anyone help me for this problem

// Upload Form
<?php
include("connect.php");

$_SESSION['username']= 'ram';
$username=$_SESSION['username'];

if(isset($_POST['submit']))
{
        //get file attributes

        $name=$_FILES['myfile']['name'];
        $tmp_name=$_FILES['myfile']['tmp_name'];

        if($name)
        {
                //start upload process

                $location="$name";
                move_uploaded_file($tmp_name,$location);
                $query=mysql_query("UPDATE members SET imagelocation='$location' WHERE username='$username'");
                die("Your Avatar has been uploaded!! <a href='view.php'></a>");
                
        }
        else
        {
                echo "Please upload a file";
        }       
}




echo "upload image: <br>

<form action='upload.php' method='POST' enctype='multipart/form-data'>

File:<input type='file' name='myfile'><input type='submit' name='submit' Value='Upload'
</form>

";



?>

//View  Form

<?php
require("connect.php");
 
$username=$_SESSION['username'];
$query=mysql_query("SELECT *FROM members WHERE username='$username'");
if(mysql_num_rows($query)==0)
        die("User not found!!!!");
else
{
        $row=mysql_fetch_assoc($query);
        $location=$row['imagelocation'];
        echo "<img src='$location' width='100' height='100'>";
}
?>
3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by ko ko
0

In line no 5 the $_SESSION["username"] is always set to "Ram". Thats why the problem. Please check that line.

0

In line no 5 the $_SESSION["username"] is always set to "Ram". Thats why the problem. Please check that line.

when i removing the user session ram can't upload image in my user table.
how to set any user has login and update image

0

'session_start()' requires on your page. But, it might be the first before output any HTML or processing PHP codes.

<?php
session_start();
?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.