duplicate post items
<p>I am experiencing a strange problem and I shall try to explain best I can. i am using jQuery dialog for form submissions and all works well apart from the fact that when I first open the form and click submit it submits the form and enters the data in the db correctly. however, if I then open another form and submit it creates 2 posts of the same data. it increments the post by 1 on each submission. if I however refresh the browser it post 1 correct entry. Why do I have to keep refreshing the browser to post correctly? I have posted the code I am using and would be grateful if someone could show me my error. Many thanks</p>

<p>PS. assume all connections to db are correct.</p>

<pre><code>jQuery dialog code
==================================================

function feedbacknew() 
{    
    $("#form").dialog(
    {
        autoOpen: false,
        resizable: false,
        modal: true,
        title: 'Submit a feedback request',
        width: 460,
        height: 490,
        beforeclose: function(event, ui) { $("#message").html(""); }

    });

    $('#submit').click(function () 
    {
        var name = $('.uname').val();
        var company = $('#company').val();
        var email = $('.email').val();
        var position = $('.position').val();
        var feedback = $('.feedbacknew').val();
        var data = 'uname=' + encodeURIComponent(name) + "&amp;company=" + encodeURIComponent(company) + "&amp;email=" + encodeURIComponent(email) + "&amp;position=" + encodeURIComponent(position) + "&amp;feedback=" + encodeURIComponent(feedback);
        $.ajax(
        {
        type: "POST",
        url: "feedback.php",
        data: data,
        success: function (data) {
            $("#feedback").get(0).reset();
            $('#message').html(data);
            //$("#form").dialog('close');
            $("#flex1").flexReload();
            } 
        });
        return false;

    });

    $("#form").dialog('open');

}


![html form code
====================================================

// Feedback form
&lt;div id="form" style="display:none;"&gt;
  &lt;form method="post" id="feedback" class="webform" name="feedback"&gt;


        &lt;label for="company"&gt;Company&lt;/label&gt;
        &lt;select name="company" id="company"&gt;
          &lt;option SELECTED VALUE=""&gt;Select an option&lt;/option&gt;
          &lt;option value="Technical"&gt;Technical&lt;/option&gt;
          &lt;option value="Database"&gt;Database&lt;/option&gt;
          &lt;option value="Error"&gt;Error&lt;/option&gt;
          &lt;option value="Other"&gt;Other&lt;/option&gt;
        &lt;/select&gt;
        &lt;label for="name"&gt;Full Name:&lt;/label&gt;
        &lt;input id="uname" name="uname"  type="text" class="text ui-widget-content ui-corner-all inputbox uname" value="&lt;?php echo $_SESSION['kt_name_usr']; ?&gt;" /&gt;
        &lt;label for="email"&gt;Email address:&lt;/label&gt;
        &lt;input id="email" name="email" type="text" class="text ui-widget-content ui-corner-all inputbox email" value="&lt;?php echo $_SESSION['kt_email_usr']; ?&gt;"/&gt;
        &lt;label for="position"&gt;Position:&lt;/label&gt;
        &lt;input id="position" name="position" type="text" class="text ui-widget-content ui-corner-all inputbox position" /&gt;
        &lt;label for="feedbacknew"&gt;Feedback:&lt;/label&gt;
        &lt;textarea id="feedbacknew" name="feedbacknew" cols="25" rows="3" type="text" class="text ui-widget-content ui-corner-all inputbox feedbacknew"&gt;Please make sure that any error messages or numbers are listed here &lt;/textarea&gt;&lt;br /&gt;

        &lt;button id="submit" class="submit"&gt;Submit&lt;/button&gt;
        &lt;div id="message"&gt;&lt;/div&gt;
  &lt;/form&gt;
&lt;/div&gt;

deedback.php code
=============================================

&lt;?php
$company = $_POST['company'];
$name = $_POST['uname'];
$email = $_POST['email'];
$position = $_POST['position'];
$feedback = $_POST['feedback'];

?&gt;
&lt;div style="padding:2px; color:#ff0000;font-size:12px;font-weight:normal"&gt;&lt;?php echo "&lt;br /&gt;" . "Thank you. You can now close this window." . "&lt;br /&gt;"; ?&gt;&lt;/div&gt;

&lt;?php

mysql_query("INSERT INTO feedback (department, name, email, position, feedback, date) VALUES ('$company', '$name', '$email', '$position', '$feedback', NOW())");
?&gt;][1]
</code></pre>
