日期:2014-05-17 浏览次数:20443 次
<html> <head> book entry result </head> <body> <h1>book entry result</h1> <?php header("content-type:text/html;charset=utf-8"); $isbn=$_POST['isbn']; $author=$_POST['author']; $title=$_POST['title']; $price=$_POST['price']; if(!($isbn||$author||$title||$price)) { echo"请确认每行都输入数据"; exit; } if(!get_magic_quotes_gpc()) { $isbn=addslashes($isbn); $author=addslashes($author); $title=addslashes($title); $price=addslashes($price); } mysql_query('set names utf8'); @$db=new mysqli('localhost','root','root','books'); if(mysqli_connect_error()) { echo "链接数据库不成功"; exit; } header("content-type:text/html;charset=utf-8"); $query="insert into books(isbn ,author ,title ,price) values('".$isbn."', '".$author."', '".$title."', '".$price."')"; $result=$db->query($query); if($result){ echo $db->affected_rows." 本书数据录入成功。"; }else{ echo"数据录入失败。"; } ?> </body> </html>