javascript - ajax causing mysql duplicate entry? -


i using following ajax script run mysql function , insert entry table. working fine except duplicating entry twice.

<script type="text/javascript"> $(document).ready(function() {     $('#support1').click(function(e) {         var sel_stud = "support1";         $.ajax({             type: "post",             url: "include/run_support_log.php",             data: 'theoption=' + sel_stud,             success: function() {                 $('#support_content').show();             }         });     }); }); </script> 

mysql:

<?php  session_start(); include 'config.php';  $type = $_post['theoption']; if($type == "support1"){ $type = "phone support"; }    $random = 's' . substr( md5(rand()), 0, 7); echo $random;   $query = "insert supplier_log (id, reference, user_id, date, activity_type) values ('', '$reference','{$_session['id']}', now(), '$type')"; $result = mysql_query($query);  if($result) {     echo 'success'; }  ?> 

please can show me abouts going wrong? in advance

are sure the line

include 'config.php'; 

isn't including script second time?

it shouldn't, cause make infinite loop. check in case.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -