如何在PHP中将数据保存到mysql数据库 [英] How to save data to mysql database in PHP

查看:110
本文介绍了如何在PHP中将数据保存到mysql数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试学习如何创建注册,并且正在观看视频来执行此操作,但问题是我按照他们的步骤但我的数据库连接不起作用,我测试它以回显第一个,最后一个,用户名和注册按钮被击中时的密码,但案例是它返回我的signup.php代码,请帮我解决问题,我是php和mysql的新手。



我尝试过:



这是我的signup.php代码





<?php



包括'dbh.php';



$ first = $ _POST ['first'];

$ last = $ _POST ['last'];

$ uid = $ _POST [ 'uid'];

$ pwd = $ _POST ['pwd'];

echowelcome;

echo $ first。
;

echo $ last。
;

echo $ uid。
;

echo $ pwd。
;



这是我的dbh.php代码



<? php



$ conn = mysqli_connect(localhost ,,logintest);



if(!$ conn){

die(Connection failed.mysqli_connect_error( ));

}

i am trying to learn how to create a signup,and am watching a video to do that,but the problem is i followed their steps but my database connection is not working,i tested it to echo the first,last,username and password when signup button is hit,but the case is that it returns me to my signup.php code,please i did help to resolve the issue,am new to php and mysql.

What I have tried:

this my signup.php code


<?php

include 'dbh.php';

$first = $_POST['first'];
$last = $_POST['last'];
$uid = $_POST['uid'];
$pwd = $_POST['pwd'];
echo "welcome";
echo $first."
";
echo $last."
";
echo $uid."
";
echo $pwd."
";

this my dbh.php code

<?php

$conn = mysqli_connect("localhost","","logintest");

if(!$conn){
die("Connection failed".mysqli_connect_error());
}

推荐答案

first =


_POST ['first'];
_POST['first'];


last =


这篇关于如何在PHP中将数据保存到mysql数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆