用户注册时如何将数据插入数据库? [英] How Do I Insert Data Into The Database When A User Signs Up ?
本文介绍了用户注册时如何将数据插入数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在创建一个论坛网站,当用户注册时,我希望用户信息进入数据库表,但我找不到办法。我尝试了各种方式,如youtube教程和其他论坛,但没有任何帮助我。我甚至尝试过网站上的教程,为你提供代码,但没有任何帮助。有人可以帮我解决代码或错误吗?我会很感激。这是我的register.php文件:
I am creating a forum website and when the user signs up i want the users information to go into the databases table but i cant find a way to do it . i tried various ways like youtube tutorials and other forums but nothing is helping me . i even tried tutorials from websites tat give you the code , but nothing helps. Can someone help me with code or an error i have ? I would appreciate it a lot. This is my register.php file :
<?php
include('db.php');
?>
<html>
<head>
<title>InterFace</title>
<link rel="stylesheet" type="text/css" href="css.css" >
</head>
<body bgcolor="#E6E6FA">
<nav>
<div id="logo">
<h1> InterFace</h1>
</div>
</nav>
<form action="" method="POST">
<p align="right"><input type="text" name="firstname" size="35" id="First Name" placeholder="First Name" /></p>
<br></br>
<p align="right"><input type="text" name="lastname" size="35" id="Last Name" placeholder="Last Name" /></p>
<br></br>
<p align="right"><input type="text" name="username" size="35" id="Username" placeholder="User Name" /></p>
<br></br>
<p align="right"><input type="password" name="password" size="35" id="Password" placeholder="Password" /></p>
<br></br>
<p align="right"><input type="password" name="password2" size="35" id="Password2" placeholder="Confirm Password" /></p>
<br></br>
<p align="right"><input type="text" name="email" size="35" id="Email" placeholder="E-mail" /></p>
<br></br>
<p align="right"><input type="text" name="email2" size="35" id="Email2" placeholder="E-mail confirm" /></p>
<p align="right"><input type="submit" name="reg" value="Submit"></p>
</form>
</body>
</html>
这是我的数据库连接文件:
This is my database connection file :
<?php
$mysqli_hostname = "127.0.0.1";
$mysqli_username = "root";
$mysqli_password = "";
$mysqli_database = "interface";
$db = mysqli_connect ($mysqli_hostname, $mysqli_username, $mysqli_password)
or die("Something is broken") ;
?>
推荐答案
mysqli_hostname = 127.0.0.1;
mysqli_hostname = "127.0.0.1";
mysqli_username = 根跨度>;
mysqli_username = "root";
mysqli_password = 跨度>;
mysqli_password = "";
这篇关于用户注册时如何将数据插入数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文