mysqli を使用して MYsql テーブルに作成したフォームからデータを挿入しようとしていますが、フォームを送信するたびに、正常に接続された db サーバーが表示されます。何か案は?挿入のエラーが表示されるはずですよね?
<?php
if ($_POST['submit']) {
$errormsg = "";
$name = $_POST['name'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$connection = @mysqli_connect("$hostname","$username", "$password", "$database");
if(!$connection){
die("<p>The database server is not available.</p>".mysqli_error());
}
echo "<p>Sucessfully connected to the database server.</p>";
if((!$name)||(!$password)||(!$password2)||(!$email)||(!$phone)){ /* Checks if all inputs are filled*/
$errormsg = "Please insert the required fields below<br />";
if ($name == "")
{
$errormsg = $errormsg . "Enter a name.<br />";
}
if ($password == "")
{
$errormsg = $errormsg . "Please enter a password.<br />";
}
if ($password2 =="")
{
$errormsg = $errormsg . "Please re-enter your password.<br />";
}
if ($email =="")
{
$errormsg = $errormsg . "Please enter an email address.<br />";
}
if ($phone =="")
{
$errormsg = $errormsg . "Please enter a phone number.<br />";
}
if($errormsg){
echo "$errormsg";
}
}
if($password != $password2) {
$errormsg = $errormsg. "Your passwords must match!<br/>";
}
function checkEmail($email){ //begin email check function
$sql = "SELECT count(email) FROM CUSTOMER WHERE email='$email'";
$result = mysqli_result(mysqli_query($sql),0);
if( $result > 0 ){
$errormsg = $errormsg. "There is already a user with that email!";
}//end email check function
if(!$errormsg)
{
$insertquery = "INSERT INTO CUSTOMER (customer_no, name, password, email, phone)
VALUES(NULL, '$name', '$password', '$email', '$phone')";
$queryresult = mysqli_query($insertquery);
if($queryresult)
{
echo("<br>Registration sucessful");
}
else
{
echo("<br>registration was not sucessful");
}
}
}
}
?>