php如何获得http post的数据

php如何获得http post的数据,第1张

PHP获取POST数据的几种方法:

方法1、最常见的方法是:$_POST['fieldname'];

说明:只能接收Content-Type: application/x->和 $>

你是不是想问php如何让获取数据库内容并传到前端

$serverName = "localhost";//数据库地址这是本地的

$sqlUserName = "root";//数据库管理员账号

$sqlPwd = "root123";//数据库管理员密码

$dBName = "phptest";//数据库表名

$port="3308";//端口

//mysqli连接数据库语句正确返回true错误返回false

$link = @mysqli_connect($serverName,$sqlUserName,$sqlPwd,$dBName,$port);

if($link) {

mysqli_query($link,'set names utf8');

$sql = " select from adminhtmlval ";//查询语句

$query = mysqli_query($link,$sql);//mysqli执行语句e

if ($query){

$i=0;

while ($arr = mysqli_fetch_array($query)){

$navArr[$i] = $arr;

$i++;

//页面直接调用$navArr,也可以在这个循环体内直接输出

}

第一种,使用smarty模板引擎

php文件:

$smarty->assign('data','hello world');

$smarty->display('indexhtml');

indexhtml文件:

<div>{$data}</div>

输出hello world

第二种,使用PHP变量直接输出

php文件:

$data = 'hello world';

require 'indexhtml';

indexhtml:文件:

<div><php echo $data;></div>

以上就是关于php如何获得http post的数据全部的内容,包括:php如何获得http post的数据、用PHP获取网页部分数据、php如何读取dbr数据库并传到前端等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/9313641.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-27
下一篇 2023-04-27

发表评论

登录后才能评论

评论列表(0条)

保存