我是php.my的新用户,输入表单没有将任何内容保存在我的PHPMYADMIN数据库中,但是每次我按我的REGISTER按钮时,它都会显示“ register = success”即使它没有插入到我的数据库中,也没有在任何行中显示任何错误。___________________________________________________________________________
this what inside my index.php
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
</head>
<body>
<div class="container" >
<form id="BG" class="col-lg-8" action="includes/register.php" method="POST">
<div class="form-group">
<label for="formGroupExampleInput">Firstname</label>
<input type="text" class="form-control col-lg-6" id="formGroupExampleInput" placeholder="Firstname" name="fName">
</div>
<div class="form-group">
<label for="formGroupExampleInput2">Lastname</label>
<input type="text" class="form-control col-lg-6" id="formGroupExampleInput2" placeholder="Lastname"name="lName">
</div>
<div class="form-group">
<label for="formGroupExampleInput">Plate #</label>
<input type="text" class="form-control col-lg-6" id="formGroupExampleInput" placeholder="Plate #"name="plateNo">
</div>
<div class="form-group">
<label for="formGroupExampleInput2">Vehicle brand</label>
<input type="text" class="form-control col-lg-6" id="formGroupExampleInput2" placeholder="Vehicle brand"name="vBrand">
</div> <div class="form-group">
<label for="formGroupExampleInput">color</label>
<input type="text" class="form-control col-lg-6" id="formGroupExampleInput" placeholder="color"name="color">
</div>
<button type="submit" name="submit" class="btn btn-primary">Register</button>
</form>
</div>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.slim.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" ></script>
</html>
_____________________________________________________________________________
this is inside my register.php
<?php
include_once 'includes/conn.php';
$fname=$_POST['fName'];
$lName=$_POST['lName'];
$plateNo=$_POST['plateNo'];
$vBrand=$_POST['vBrand'];
$color=$_POST['color'];
$sql = "INSERT INTO register(name,lastname,Plateno,vehiclebrand,color)
VALUES($fname,$lName,$plateNo,$vBrand,$color);";
mysqli_query($conn,$sql);
header("Location: ../index.php?register=success");
?>
_____________________________________________________________________________
这是在我的conn.php中
<?php
$dbSname='localhost';
$dbUname ='root';
$pwd='';
$dbName = 'capstone';
$conn = mysqli_connect($dbSname,$dbUname,$pwd,$dbName);
我期望我的输入将数据保存到我的phpmyadmin数据库中
首先,您需要知道在运行查询时是否发生错误。因此,我的建议是更改您的。php
脚本以处理异常,如下所示: