I used the php code in javascript function.When i click a button the javascript function is called and in that function i wrote the php code for insert values in database.With out submit the button the values are inserted into database.How can i prevent the inserting values without submitting the button?
Here is my script :
Here is my script :
Code:
<script>
function insfun()
{
<?php
$query=mysql_query("select * from tbl_products");
while($row=mysql_fetch_array($query))
{
$queryins=mysql_query("insert into tbl_rateit(email,uid,action,item) values ('$_SESSION[email]','$_SESSION[uid]','buy','$row[itemid]')");
}
?>
}
</script>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="image" src="../x-click-but01.gif" name="submit" onclick="return insfun();">
</form>
Comment