<?php header("Content-type: text/html;charset=utf-8"); $con = mysql_connect("localhost","root","root");//连接数据库 if (!$con){ die(‘Could not connect: ‘ . mysql_error()); } mysql_select_db("web", $con);//打开数据库 mysql_query("set names utf8"); $sql="INSERT INTO users (username, password) VALUES (‘$_POST[username]‘,‘$_POST[password]‘)";//插入数据 if (!mysql_query($sql,$con)){ die(‘Error: ‘ . mysql_error()); echo "0"; } echo "1"; mysql_close($con); ?>
时间: 2025-01-04 19:05:44