Save image url path in DB columns
<p>i am updating name , email in DB of registered user through php form. its working fine.</p>

<p><strong>class.usr.php</strong></p>

<pre><code>public function update($uname,$email, $tax)
    {
    try {
    $stmt = $this-&gt;conn-&gt;prepare('UPDATE tbl_users SET userName = ?, userEmail = ? , tax = ?  WHERE userID = ? ');
    $stmt-&gt;execute(array($uname,$email, $tax , $_SESSION['userSession']));
    return $stmt-&gt;fetch();
    } catch(PDOException $e) {
        echo '&lt;p class="bg-danger"&gt;'.$e-&gt;getMessage().'&lt;/p&gt;';
    }
</code></pre>

<p><strong>form</strong></p>

<pre><code>&lt;form action="profile.php" method="POST" enctype="multipart/form-data"&gt;

Name : 
&lt;input type="text" name="txtuname" value="&lt;?php echo $row['userName'] ?&gt;" /&gt;&lt;br/&gt;
Email :
&lt;input type="text" name="txtemail" value="&lt;?php echo $row['userEmail'] ?&gt;" /&gt;&lt;br&gt;
Image
&lt;input type="file" name="photo" id="fileSelect"&gt;&lt;br&gt; 

&lt;input type="submit" name="submit" value="Save" /&gt;

&lt;/form&gt;
</code></pre>

<p><strong>form related code to save in db</strong></p>

<pre><code>&lt;?php

$user_home = new USER();

if(!$user_home-&gt;is_logged_in())
{
    header("Location: index.php");
die();
}

if (isset($_POST['submit'])) {
// new data
$uname = $_POST['txtuname'];
$email = $_POST['txtemail'];
$tax = trim($_POST['tax']); // image url path

$uid = (isset($_SESSION['userSession']) ? intval($_SESSION['userSession']) : 0);

if ($uid &gt; 0 &amp;&amp; $user_home-&gt;update($uname,$email, $tax, $uid))
{
    header("Location: profile1.php");
   die(); 
}
}

$stmt = $user_home-&gt;runQuery("SELECT * FROM tbl_users WHERE userID=:uid");
$stmt-&gt;execute(array(":uid"=&gt;$_SESSION['userSession']));
$row = $stmt-&gt;fetch(PDO::FETCH_ASSOC);

?&gt;
</code></pre>

<p>after this, now i am uploading an image to folder through same php form successfully with below code.</p>

<pre><code>    &lt;?php 
if(isset($_FILES["photo"]["error"])){ 
if($_FILES["photo"]["error"] &gt; 0){ 
echo "Error: " . $_FILES["photo"]["error"] . "&lt;br&gt;"; 

} else{ 
$allowed = array("jpg" =&gt; "image/jpg", "jpeg" =&gt; "image/jpeg", "gif" =&gt; "image/gif", "png" =&gt; "image/png"); 
$filename = $_FILES["photo"]["name"]; 
$filetype = $_FILES["photo"]["type"]; 
$filesize = $_FILES["photo"]["size"]; 

// Verify file extension 
$ext = pathinfo($filename, PATHINFO_EXTENSION); 
if(!array_key_exists($ext, $allowed)) die("Error: Please select a valid file format."); 

// Verify file size - 5MB maximum 
$maxsize = 5 * 1024 * 1024; 
if($filesize &gt; $maxsize) die("Error: File size is larger than the allowed limit."); 

// Verify MYME type of the file 
if(in_array($filetype, $allowed)){ 
// Check whether file exists before uploading it 
if(file_exists("upload/" . $_FILES["photo"]["name"])){ 
echo $_FILES["photo"]["name"] . " is already exists."; 

} else{ 
move_uploaded_file($_FILES["photo"]["tmp_name"], "upload/" . $_FILES["photo"]["name"]); 

echo "Your file was uploaded successfully."; 
} 
} else{ 

echo "Error: There was a problem uploading your file - please try again."; 
} 

} 

} else{ 
echo ""; 
} 

?&gt;
</code></pre>

<p>now images are just saving in folders, what i need is <strong>i want that image path to save in database and assign that image path to uploaded user in database.</strong> so that one registered user can update the existing image, but not upload one more image.</p>

<p>i tried below code , but not working:</p>

<pre><code>&lt;?php
$folder = "upload/"; 
    $file = basename( $_FILES['image']['name']); 
    $full_path = $folder.$file; 
    $tax= $full_path;

    if(in_array($filetype, $allowed)){ 
// Check whether file exists before uploading it 
if(file_exists("upload/" . $_FILES["photo"]["name"])){ 
echo $_FILES["photo"]["name"] . " is already exists."; 

} else{ 
move_uploaded_file($_FILES["photo"]["tmp_name"], "upload/" . $_FILES["photo"]["name"]); 

echo "Your file was uploaded successfully."; 
} 
} else{ 

echo "Error: There was a problem uploading your file - please try again."; 
} 

} 

} else{ 
echo ""; 
} 
?&gt;
</code></pre>

<p><strong>db columns</strong> : userName, userEmail, tax , photo</p>

<p>with help of google i done all above, i am new to php, so please kindly help me. </p>