
正文
php登录界面数据库插入 php页面添加数据到数据库
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
php可不可通过前端界面输入信息数据库中多个表插入该信息
可以啊。你后台接收到界面的值之后封装到sql里面去,然后执行sql就可以了
相关问答
Q1: php 实现简单的注册页面 并把注册信息插入到 mysql 数据库中
注册页面:reg.html
form action="reg.php" method="POST"
table
trtd用户名:/tdtdinput type="username" size="20"/td/tr
trtd密码:/tdtdinput type="userpass" size="20"/td/tr
trtd确认密码:/tdtdinput type="ruserpass" size="20"/td/tr
trtd邮箱:/tdtdinput type="email" size="50"/td/tr
trtd电话:/tdtdinput type="telphone" size="20"/td/tr
trtdinput type="Submit" value="注册"/td/tr
/table
/form
接收页面:reg.php
%php
$db = mysql_connect("localhost", "root", "12345");
mysql_select_db("dataname", $db);
mysql_query("insert into tablename(username, userpass, email, telphone) values('$_POST[username]', '$_POST[userpass]', '$_POST[email]', '$_POST[telphone]')");
echo "注册成功";
%
Q2: php 分别写出用户登录页和post数据传送方式下的数据库插入的程序段(注:用户登录页为index
?php
if(isset($_POST["submit"]) $_POST["submit"] == "登陆")
{
$user = $_POST["username"];
$psw = $_POST["password"];
if($user == "" || $psw == "")
{
echo "scriptalert('请输入用户名或密码!'); history.go(-1);/script";
}
else
{
mysql_connect("localhost","root","");
mysql_select_db("vt");
mysql_query("set names 'gbk'");
$sql = "select username,password from user where username = '$_POST[username]' and password = '$_POST[password]'";
$result = mysql_query($sql);
$num = mysql_num_rows($result);
if($num)
{
$row = mysql_fetch_array($result); //将数据以索引方式储存在数组中
header("location:QA.php");
echo $row[0];
}
else
{
echo "scriptalert('用户名或密码不正确!');history.go(-1);/script";
}
}
}
else
{
echo "scriptalert('提交未成功!'); history.go(-1);/script";
}
?
这里提供个参考
Q3: PHP网页制作,怎样把注册表单的数据导入MySQL数据库?
首先php登录界面数据库插入你要建立一个表php登录界面数据库插入,例如是注册的用户表user
,里面的结构有字段
id,
name,nickname,email等。
然后在你的表单处form
action="a.php"
method="post"
name="regform"(如果有图片上传,还要加上enctype="multipart/form-data")
,那么点击表单提交按纽后,此表单将会交给处理页a.php来作处理。
如果简单点,你就直接可以将表单传递过来的数据$_POST,直接用sql插入语句,insert
into来插入到数据库,表user中。例如insert
into
user
set
name='".$_POST['name']."'.............................
Q4: PHP在网站上实现跟数据库添加数据
把来自表单的数据插入数据库
现在,我们创建一个 HTML 表单,这个表单可把新记录插入 "Persons" 表。
这是这个 HTML 表单:
html
body
form action="insert.php" method="post"
Firstname: input type="text" name="firstname" /
Lastname: input type="text" name="lastname" /
Age: input type="text" name="age" /
input type="submit" /
/form
/body
/html
当用户点击上例中 HTML 表单中的提交按钮时,表单数据被发送到 "insert.php"。"insert.php" 文件连接数据库,并通过 $_POST 变量从表单取回值。然后,mysql_query() 函数执行 INSERT INTO 语句,一条新的记录会添加到数据库表中。
下面是 "insert.php" 页面的代码:
?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
$sql="INSERT INTO Persons (FirstName, LastName, Age)
VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[age]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con)
?
php登录界面数据库插入的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于php页面添加数据到数据库、php登录界面数据库插入的信息别忘了在本站进行查找喔。








