Javascript函数内的PHP代码无法正常工作(插入)

时间:2016-04-25 07:37:47

标签: javascript php mysql web phpmyadmin

PHP插入查询不向数据库发送任何内容,也许是因为它在Javascript函数中,我还不知道..任何人都可以帮忙吗?感谢。



<script>
function getMeta(){   
    var img = new Image();
    img.onload = function(){
        if (this.width != 468 && this.height != 60)
		  {alert( 'Error : only these image sizes are accepted : 468x60' );
		  return false;}
		  
		  else
		  alert( 'loaded successfully' );
		  document.getElementById('form1').submit();
		  <?php

            include("connection.php");
            $email=$_POST["t1"];
            $email=addslashes($email);
	        $img=$_POST["t2"];
	        $img=addslashes($img);
	        $target=$_POST["t3"];
	        $target=addslashes($target);
  
            $sql=mysql_query("insert into b1(email, img, target) values  ('$email', '$img', '$target')");
   
?>

    };
	img.onerror = function() {alert( 'Error : this is not a valid image');
	return false;
	 };
    img.src = document.getElementById('t2').value;
	return true;
}


</script>
&#13;
&#13;
&#13;

0 个答案:

没有答案