Submit and fetch data without refreshing the page
<p>I'm new to php and mySQL. I've created a webpage, it's essentially a noticeboard. The page has a form to submit content and the content is shown below instantaneously. The content appears when the submit button is pressed, but now if I wanted to submit content immediately after the form still displays the echo that says submission was successful. Could someone point me in right direction to get the page functioning in a way that users can submit content one after the other without refreshing the page? Any help is greatly appreciated. Apologies for the messy code.</p>

<p>This is my input code:</p>

<pre><code>        if(! $conn ) {
           die('Could not connect: ' . mysql_error());
        }

        if(! get_magic_quotes_gpc() ) {
           $name = addslashes ($_POST['name']);
           $proposal = addslashes ($_POST['proposal']);
        }else {
           $name = $_POST['name'];
           $proposal = $_POST['proposal'];
        }

       $email = $_POST['email'];

        $sql = "INSERT INTO db3". "(name, proposal, email, join_date ) 
            VALUES('$name','$proposal','$email', NOW())";

        mysql_select_db('_db');
        $retval = mysql_query( $sql, $conn );

        if(! $retval ) {
           die('Could not enter data: ' . mysql_error());
        }

       echo "&lt;div class='msg-box' id='msg-box'&gt;Entered data successfully&lt;/div&gt;\n";

        mysql_close($conn);
</code></pre>

<p>This is my form:</p>

<pre><code>&lt;form name="submission" method = "post" action = "&lt;?php $_PHP_SELF ?&gt;" &gt;

      &lt;fieldset&gt;
         &lt;input name = "name" type = "text" 
                       id = "name" placeholder="Name..." required autocomplete="off"&gt;

         &lt;input name = "email" type = "text" 
                       id = "email" placeholder="example@gmail.com..."  autocomplete="off"&gt;

         &lt;textarea name = "proposal" type = "textarea" maxlength="1000" 
                       id = "proposal" placeholder="Your proposal goes here..." required autocomplete="off"&gt;&lt;/textarea&gt;


      &lt;/fieldset&gt; 

      &lt;fieldset&gt; 
         &lt;input name = "add" type = "submit" id = "add" value = "Submit"&gt; 
      &lt;/fieldset&gt;

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

<p>This is my retrieval code:</p>

<pre><code>  $conn = mysql_connect($dbhost, $dbuser, $dbpass);

  if(! $conn ) {
  die('Could not connect: ' . mysql_error());
  }

   $sql = 'SELECT id, name, proposal FROM db3 ORDER BY ID DESC ';

   mysql_select_db('_db');
   $retval = mysql_query( $sql, $conn );

   if(! $retval ) {
      die('Could not get data: ' . mysql_error());
   }

   while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) {
     echo 
      "&lt;article&gt;".
      " &lt;div class='id'&gt; ID :{$row['id']} &lt;/div&gt;  ".

      " &lt;section&gt; &lt;p&gt; {$row['proposal']} &lt;/p&gt;&lt;/section&gt; ".
        " &lt;section class='name'&gt;&lt;h3&gt; {$row['name']} &lt;/h3&gt;&lt;/section&gt; ".
       "&lt;/article&gt;"
      ;   

    }


   mysql_close($conn);
   ?&gt;
</code></pre>