here is my code for image upload. after upload successfully i want to go my mainpage.php page . i am using iframe to display upload form. how to go mainpage. please anyone help me for this problem .

<?php

include("connect.php");

$_SESSION['MM_Username'] ;
$username=$_SESSION['MM_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 avatar='$location' WHERE username='$username'");
                die();
                
        }
        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>";

?>

Recommended Answers

All 2 Replies

After your update query redirect your page to main page.
So you have to include this line after your query line (line no : 23):

header("Location: main.php");

If this in not your requirement, Please be more specific.

commented: Yes +5

Or include the page you want to display using include() function

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.