gpt4 book ai didi

php - 插入数据 mysqli 不工作

转载 作者:太空宇宙 更新时间:2023-11-03 11:46:21 25 4
gpt4 key购买 nike

这是我的带有表单部分的 HTML...我不明白我的错误在哪里

<!DOCTYPE html>
<html>

<head>
<title></title>
<link rel="stylesheet" type="text/css" href="loginStyle.css">
<link href="Bootstrap/css/bootstrap.min.css" rel="stylesheet">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1 user-scalable=no">
<link href='https://fonts.googleapis.com/css?family=Jura:600' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="Font Awseome Glyphicons/css/font-awesome.min.css">
<link href='https://fonts.googleapis.com/css?family=Lora:700' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Lato' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="Owl Carousel/owl-carousel/owl.carousel.css">
<link rel="stylesheet" href="Owl Carousel/owl-carousel/owl.theme.css">
</head>

<body>


<div class="container">
<div class="row">
<div class="col-md-12" style="margin-top:8%">
<h2 class="text-center">Be a Part of World</h2>
</div>
</div>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<form role="form" id="loginForm" action="regCheck.php" method="POST">
<div class="form-group">
<label for="regName">
<h4>Name</h4>
</label>
<input type="text" id="regName" class="form-control" placeholder="Your name here..." name="name">
<div class="alert"></div>
</div>
<div class="form-group">
<label for="regLogin">
<h4>Login</h4>
</label>
<input type="text" placeholder="Login Here..." id="regLogin" class="form-control" name="login">
<div class="alert"></div>
</div>
<div class="form-group">
<label for="regPass">
<h4>Password</h4>
</label>
<input type="password" placeholder="Password Here..." id="regPass" class="form-control" name="pass">
<div class="alert"></div>
</div>
<div class="form-group">
<input type="submit" value="Sign Up" class="btn btn-danger btn-lg" id="regSubmit" name="submit">
</div>
</form>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h3 class="text-center"><strong>...0r Join Us With</strong></h3>
</div>
</div>
<div class="row">
<div class="col-md-6 col-md-offset-4">
<ul class="list-inline">
<li><a href="facebook.com"><span class="fa fa-facebook-official " aria-hidden="true"></span> Facebook</a>
</li>
<li><a href="twitter.com"><span class="fa fa-twitter" aria-hidden="true"></span> Twitter</a>
</li>
<li><a href="youtube.com"><span class="fa fa-youtube " aria-hidden="true"></span> Youtube</a>
</li>
<li><a href="instagram.com"><span class="fa fa-instagram " aria-hidden="true"></span> Instagram</a>
</li>
</ul>
</div>
</div>
</div>

<script type="text/javascript" src="JQuery/jquery-1.11.3.min.js"></script>
<script src="Owl Carousel/owl-carousel/owl.carousel.js"></script>
<script src="Bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="script.js"></script>
</body>

</html>

这里是检查注册的部分

<?php
$con = mysqli_connect("localhost", "root", "");
if (!$con) {
die("Failed Databse Connection");
}

$name = $_POST["name"];
$login = $_POST["login"];
$pass = $_POST["pass"];
$query = "INSERT INTO db_users(name, pass,login) VALUES ('$name', '$pass', '$login')";

if (isset($_POST["submit"])) {
mysqli_query($con, $query);
}
?>

最佳答案

您的 mysqli 语法与简单的 mysql 混合

你必须在 mysqli_connect 中将数据库名称作为最后一个参数

$con = mysqli_connect("localhost","root","","databasename");

关于php - 插入数据 mysqli 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38457410/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com