我遇到了問題,我的數據沒有通過phpMyAdmin。服務器和數據庫連接PHP,但數據未插入到表中。插入的數據不會去phpMyAdmin數據庫
這是我到目前爲止。
<?php
$dbConnect = mysqli_connect("xxxxxxx", "xxxxx","xxxxx");
if (!$dbConnect)
die("<p>The database server is not available.</p>");
echo "<p>Successfully connected to the database server.</p>";
$dbSelect = mysqli_select_db($dbConnect,"sxxxxxxx_db");
if (!$dbSelect)
die("<p>The database is not available.</p>");
echo "<p>Successfully opened the database.</p>";
$sql = "INSERT INTO customer (Name,Password,Email,Phone) VALUES ('$_POST[namefield]', '$_POST[pwdfield]','$_POST[email]','$_POST[phone]') ";
mysqli_query($sql,$dbConnect);
mysqli_close($dbConnect);
if(isset($_POST['namefield']) && isset($_POST['pwdfield']) && isset($_POST['cpwdfield']) && isset($_POST['email']) && isset($_POST['phone']) && isset($_POST['submit']))
{
$name = $_POST['namefield'];
$password = $_POST['pwdfield'];
$cpassword = $_POST['cpwdfield'];
$email = $_POST['email'];
$phone = $_POST['phone'];
if ($_POST["pwdfield"] == $_POST["cpassword"])
mysqli_query("INSERT INTO user VALUES('','$password')") or die(mysqli_error());
else {
echo("Password did not match! Try again. ");
刪除mysqli_close($數據庫連接);這一行,並把它放在else塊的末尾 – RaMeSh 2015-04-06 07:22:09