Home > Backend Development > PHP Tutorial > php dynamically add records_PHP tutorial

php dynamically add records_PHP tutorial

WBOY
Release: 2016-07-21 15:47:30
Original
1034 people have browsed it

复制代码 代码如下:



插入一条新数据





















编号:
用户名:
密码:






复制代码 代码如下:

@mysql_connect("localhost", "root","1981427") //选择数据库之前需要先连接数据库服务器
or die("数据库服务器连接失败");
@mysql_select_db("test") //选择数据库mydb
or die("数据库不存在或不可用");
$id = $_POST['id'];
$username = $_POST['username'];
$password = $_POST['password'];

$query = mysql_query("insert into tablename1 values($id, '$username', '$password')");
if($query)
echo "数据插入成功";
else
echo "数据插入失败";
mysql_close();
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/319931.htmlTechArticle复制代码 代码如下: html head title插入一条新数据/title meta http-equiv="Content-Type" content="text/html; charset=gb2312" /head body form method="post" name="form1"...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template