日期:2014-05-17 浏览次数:20484 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>欢迎</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> ... $.ajax({ type:"POST", url: "xx/add_post.php", data:'aa='+escape($('#aa').val())+'&bb='+$('#bb').val(), success: function(html){ alert('添加成功!'); } }); .... <html>
<?php header("Content-Type:text/html;charset=utf-8"); date_default_timezone_set("PRC"); try{ $pdo=new PDO("mysql:host=localhost;dbname=acom", "root", "abcdefghi"); }catch(PDOException $e){ echo $e->getMessage(); } $stmt=$pdo->prepare("insert into acom_a(aa, bb) values(:aa, :bb)"); $stmt->execute(array(":aa"=>$_POST["aa"], ":bb"=>$_POST["bb"])); ?>