php help needed
<p>hello i made this script but i cant get to stop the form from submiting when refreshed
i tryed header("location: //");
etc</p>

<p>Please help </p>

<pre><code>&lt;?php
    require ('scripts/login.php');
    require ('scripts/upload_script.php');
?&gt;
&lt;html&gt;
   &lt;head&gt;
    &lt;title&gt;Welcome to Test&lt;/title&gt;
    &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"/&gt;&lt;/script&gt;
   &lt;/head&gt;

     &lt;style&gt;
       body {
       margin: 0;
       padding: 0;
    }
    #wrapper {
       width: 700px;
       height: auto;
       overflow: hidden;
       margin: 0 auto;
    }
    #head {
        margin-top: 5px;
       width: 698px;
       height: auto;
       overflow: hidden;
       padding-bottom: 10px;
       border: dashed #444 1px;
       background-color: #fff;
    }
    .logo {
       margin-top: 10px;
       margin-left: 10px;
       background: transparent url("../www.albsocial.com/images/logo.png") no-repeat;
       float: left;
       width: 170px;
       height: 60px;
    }
    #menu {
       float:left;
       clear: left;
       width: auto;
       height: auto;
       border: dashed 1px #333;
       padding: 5px;
       margin-top: 10px;
       margin-left: 10px
    }
    .p {
        padding: 5px;
        margin-top: 10px;
        margin-left: 10px;
        border: dashed 1px #333;
        float: left;
        width: auto;
        height: auto;
    }
     .t {
         float: left;
         margin-left: 75px;
         color: #555;
     }
     .name {
       float: right;
       padding: 10px;
     }
      textarea {
        resize: none;
     }
     #message {
        text-align: center;
        padding: 10px;
        background-color: red;
        color: #f3f3f3;
     }

     &lt;/style&gt;

    &lt;body bgcolor="#f5f5f5" text="#444" link="#08f" alink="#03f" vlink="#06f"&gt;

      &lt;div id="wrapper"&gt;

         &lt;div id="head"&gt;

            &lt;a href="/Testing" class="logo"&gt;&lt;/a&gt;


            &lt;?php

               if(isset($_SESSION['username'])){

                   echo "

                    &lt;div class='name'&gt;Mireserdhet &lt;a href='#'&lt;b&gt;".$_SESSION['username']."!&lt;/b&gt;&lt;/a&gt;&lt;/div&gt;

                     &lt;div id='menu'&gt;

                     &lt;b&gt;&lt;a href='titra.php'&gt;Titrat e Tua&lt;/a&gt;&lt;/b&gt;
                     &lt;br&gt;
                     &lt;b&gt;&lt;a href='upload.php'&gt;Shto Titra&lt;/a&gt;&lt;/b&gt;
                     &lt;br&gt;
                     &lt;b&gt;&lt;a href='#'&gt;Profili&lt;/a&gt;&lt;/b&gt;
                     &lt;br&gt;
                     &lt;b&gt;&lt;a href='logout.php'&gt;Logout&lt;/a&gt;&lt;/b&gt;


                     &lt;/div&gt;

                     &lt;div class='p'&gt;
                     &lt;b&gt;Vendosni Titra Ketu&lt;/b&gt;
                     &lt;br/&gt;
                     &lt;form action='upload.php' method='POST' enctype='multipart/form-data' id='form'&gt;
                        &lt;table&gt;
                        &lt;tr&gt;
                            &lt;td&gt;Titulli:&lt;/td&gt;
                            &lt;td&gt;&lt;input type='text' name='title'&gt;&lt;/td&gt;
                        &lt;/tr&gt;
                        &lt;tr&gt;
                            &lt;td&gt;Pershkrimi:&lt;/td&gt;
                            &lt;td&gt;&lt;textarea name='description' cols='35' rows='5'&gt;&lt;/textarea&gt;&lt;/td&gt;
                        &lt;/tr&gt;
                        &lt;tr&gt;
                            &lt;td&gt;&lt;/td&gt;
                            &lt;td&gt;&lt;input type='file' name='myfile'&gt;&lt;/td&gt;
                        &lt;/tr&gt;
                        &lt;tr&gt;
                            &lt;td&gt;&lt;/td&gt;
                            &lt;td&gt;&lt;input type='submit' name='submit' value='Submit' id='submit'&gt;&lt;/td&gt;
                        &lt;/tr&gt;
                        &lt;/table&gt;
                    &lt;/form&gt;&lt;/div&gt;

                    $div

                    ";

               }else{

                    header("Location: index.php");

               }

            ?&gt;

         &lt;/div&gt;

      &lt;/div&gt;

   &lt;/body&gt;

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

<p>upload_script.php</p>

<pre><code>&lt;?php

 $file = '';
 $code = '';
 $name = '';
 $echo = '';
 $div = '';

 if (isset($_POST['submit'])){
  $title = $_POST['title'];
  $description = $_POST['description'];
  $user = $_SESSION['username'];

$name = $_FILES['myfile']['name'];
$type = $_FILES['myfile']['type'];
$size = $_FILES['myfile']['size'];
$tmpname = $_FILES['myfile']['tmp_name'];
$ext = substr($name, strrpos($name, '.'));

if ($name){

    if (!in_array($type, array('text/plain'))) {

        echo "Error: Unsupported file extension. Supported extension is only .rar";

    }else if ($title &amp;&amp; $description){

        require("connect.php");
        $date = date("m-d-Y");

        $charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
        $length = 15;
        for ($i = 0; $i &lt;= $length; $i++){

            $rand = rand() % strlen($charset);
            $tmp = substr($charset, $rand, 1);
            $code .= $tmp;

        }

        $query = mysql_query("SELECT code FROM test1 WHERE code='$code'");
        $numrows = mysql_num_rows($query);


        while ($numrows != 0){

            for ($i = 0; $i &lt;= $length; $i++){

                $rand = rand() % strlen($charset);
                $tmp = substr($charset, $rand, 1);
                $code .= $tmp;

            }

            $query = mysql_query("SELECT code FROM test1 WHERE code='$code'");
            $numrows = mysql_num_rows($query);
        }
        mkdir("files/$code");
        move_uploaded_file($tmpname, "files/$code/"."$name");
        $query = mysql_query("INSERT INTO test1 VALUES ('', '$user', '$title', '$code', '$description', '$name', '$date')");

                   $div = "&lt;div id='message'&gt;Your file has been uploaded.&lt;br&gt;&lt;br&gt;            &lt;a   href='files/$code/$file/$name'&gt;Shkarkoje ketu&lt;/a&gt;&lt;/div&gt;";

       }
       else
        echo "You did not fill in the form completly."; 
       }
   else
    echo "You did not select a file.";
                }


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