while updating an user profile , if I update a new image ,it updates the new image and displays it.
If I update other fields without updating image field , it updates others, but it does not showing the image.
How to display it?

Post here some code.

editprofile.php

<?php
include('connect.php');
$ed_id=$_REQUEST['ed_id'];
$newid=mysql_query("select * from alpha where id='$ed_id'")or die(mysql_error());
$rows=mysql_fetch_array($newid);
$e=$rows['email'];
$n=$rows['username'];
$p=$rows['password'];
$rp=$rows['repeatpassword'];
$i=$rows['image']['name'];
//echo $n;
//echo $p;
//echo $e;

?>
<html>
<head>
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="css/flaty.css">
<link rel="stylesheet" href="css/flaty-responsive.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<link rel="shortcut icon" href="images/signup.jpg">
</head>
<body class="login-page">
<div class="login-wrapper">
<form name="edit" id="form-update" action="update.php" method="post" enctype="multipart/form-data" onSubmit="return(validate());">
<h3>Edit Profile</h3>
<h6> Update All..</h6>
<hr/>
<div class="form-group">
<div class="controls">
<input type="email" name="email" id="email" value="<?php echo $e; ?>" class="form-control"required/>
<input type="hidden" name="id" id="id" value="<?php echo $ed_id; ?>" class="form-control"/>
</div>
</div>
<div class="form-group">
<div class="controls">
<input type="text" name="username" id="username" value="<?php echo  $n; ?>" class="form-control" required/>
</div>
</div>
<div class="form-group">
<div class="controls">
<input type="password" name="password" id="password" class="form-control" placeholder="password" required/>
</div>
</div>
<div class="form-group">
<div class="controls">
<input type="password" name="repeatpassword" id="repeatpassword" class="form-control" placeholder="confirmpassword" required/>
</div>
</div>
<div class="form-group">
<div class="controls">
<img src="images/welcome/<?php echo $rows['image']; ?>">
<!--echo '<img  class="nav-user-photo" src="images/welcome/'.$result['image'].'" style="height:35px; width:50px">';-->
</div>
</div>
<div class="form-group">
<div class="controls">
<input type="file" name="upload"  value="<?php echo $rows['image']; ?>" class="form-control"/> <br><br>
</div>
</div>
<input type="submit" name="update" id="update" value="update"  class="btn btn-primary form-control" /><br>
</form>
</div>
</body>
</html>


update.php

<?php
include('connect.php');
$upid=$_POST['id'];
$upname=$_POST['username'];
$upemail=$_POST['email'];
$uppwd=$_POST['password'];
$uprpwd=$_POST['repeatpassword'];
$upimage=$_FILES['upload']['name'];
$newupid=mysql_query("update alpha set username='$upname', email='$upemail',password='$uppwd',repeatpassword='$uprpwd',image='$upimage' where id='$upid'")or die(mysql_error());
echo "<script type='text/javascript'> alert('Updated Successfully'); window.location.href='dashboard.php';</script>";
/*<?php
if($_POST['update'])
{
include('connect.php');
$newedid=mysql_query("update alpha set username='$n',password='$p', repeatpassword='$rp',email='$e', image='$i' where id='$ed_id'")
or die(mysql_error());
echo "<script type='text/javascript'> alert('Updated Successfully'); window.location.href='dashboard.php';</script>";
}
?>*/
?>

So, the image field in database is correct if you update other fields without updating image field? If not, maybe as you update other field, the file input type is empty and you probably update the database to empty.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.