php写入数据库追加到 php添加数据到数据库

php 接收到之后post数据写入数据库

form表单demo:task.html

成都创新互联公司专注于淮阴网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供淮阴营销型网站建设,淮阴网站制作、淮阴网页设计、淮阴网站官网定制、成都微信小程序服务,打造淮阴网络公司原创品牌,更为您提供淮阴网站排名全网营销落地服务。

fieldset id="setFiled"

legend发布任务/legend

form action="registr.php" method="post" id="steForm"

label任务类型:/labelbr

input type="text" name="type"  id="taskType" placeholder="请选择任务类型"/br

label酬nbsp;nbsp;金:/labelbr

input type="number" name="money" id="forMoney" min="1" max="1000"/label元/labelbr

label截止时间:/labelbr

input type="datetime" name="time" id="timeSubmit"/span data-year="" data-month="" data-date="" id="showDate"/spanbr

label详细描述:/labelbr

textarea maxlength="512" name="textAray" id="msgArea"/textareabr

input type="submit" name="subMit" id="forSub" value="点击发布" /

/form

扩展资料

php接收POST数据的三种方式

1、$_POST 方式接受数据

$_POST 方式是由通过HTTP的POST方法传递过来的数据组成的数组,是一个自动全局变量。

注:只能接收Content-Type:application/x-www-form-urlencode提交的数据。也就是只能接收表单过来的数据。

2、GLOBLES[‘HTTP_RAW_POST_DATA’]

如果访问原始POST数据不是php能够识别的文档类型,比如:text/xml 或者soap等等,可以用$GLOBLES[‘HTTP_RAW_POST_DATA’]来接收,$HTTP_RAW_POST_DATA变量包含有原始POST数据。此变量仅在碰到未识别的MIME数据时产生。

注:$HTTP_RAW_POST_DATA对于enctype=”multipart/form-data”表单数据不可用,也就是说使用$HTTP_RAW_POST_DATA无法接受网页表单post过来的数据。

3、file_get_contents(“php://input”);

如果访问原始POST数据,更好的方法是使用file_get_content(“php://input”);对于未指定Content-Type的POST数据,可以使用该方法读取POST原始数据,包括二进制流也可以和$HTTP_RAW_POST_DATA比起来。它带来的生存眼里更小,并且不需要任何特殊的php.ini设置。

注:php://input不能用于 enctype=”multipart/form-data”

例如:$postStr = file_get_contents("php://input"); //获取POST数据

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 mysql中如何往表中追加数据

update table set field=concat(' ', field, '072110003') where field='072110001';

应该是

update table set field=concat_ws(' ', field, '072110003') where field='072110001';

或者

update table set field=concat(field, ' ', '072110003') where field='072110001';

对于需要一次添加多个值,并且都用' '隔开的话,用第二条语句比较方便。 一次只用一个的话,concat比较简单而且不同数据库通用。

用php代码怎么往数据库里自定义插入数据

现在,我们创建一个

HTML

表单,这个表单可把新记录插入

"Persons"

表。

这是这个

HTML

表单:

123456789101112

htmlbody

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

语句,一条新的记录会添加到数据库表中。


当前标题:php写入数据库追加到 php添加数据到数据库
URL标题:http://myzitong.com/article/hiigep.html