Jump to content

How to make button auto refresh page


cruxaders

Recommended Posts

hirs the code...my proble is when i upload a image yes its upload but the problem is the previous image that he got...that still the image i see after i click submit..then i press f5 to see the updated image i uploaded....

 

what i want is after i press submit button i want the previous image will be automatic replaced by current/updated images no need to press F5

 

$id = "sir";
$sql = "SELECT * FROM `users` WHERE `username` = '".$id."'";
$res = mysql_query($sql) or die (mysql_error());


$row = mysql_fetch_assoc($res);
$location = $row ['imagelocation'];
echo "avatar <img src=\"$location\" width=\"100\" height=\"100\">";
echo "<form action=\"\" name=\"form1\" enctype=\"multipart/form-data\" method=\"post\" >";
echo "<input type=\"file\" name=\"image\" />";
echo "<input type=\"submit\" name=\"submit\" value=\"submit\" action =\"\">";
echo "</form>";

if($_POST['submit'])
{
	$name = $_FILES['image']['name'];
	$tmp_name = $_FILES['image']['tmp_name'];
	$location = "avatar/".$name;
	move_uploaded_file($tmp_name,$location);

	$sql = mysql_query("UPDATE `users` SET `imagelocation` = '".$location."' WHERE `username` = '".$id."'") or die (mysql_error());

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.