I done that coding you said, but i have to two errors:
Error 1
Fatal error: Call to a member function bind_param() on a non-object in H:\p3t\phpappfolder\public_php\project\addcustomer.php on line 21
Here is the Code
$statement->bind_param('ssssssisss', (Line 21 is here)
$_POST['title'],
$_POST['name'],
$_POST['surname'],
$_POST['firstadd'],
$_POST['secondadd'],
$_POST['city'],
$_POST['postcode'],
$_POST['phone'],
$_POST['email'],
$_POST['user'],
$_POST['password']);
Error 2
Fatal error: Call to a member function execute() on a non-object in H:\p3t\phpappfolder\public_php\project\addcustomer.php on line 23
Here is the code
$statement->execute();
But here is the full code for extra help
<?php
if (isset($_POST['title'], $_POST['name'], $_POST['surname'], $_POST['firstadd'],
$_POST['secondadd'], $_POST['city'], $_POST['postcode'], $_POST['phone'],
$_POST['email'], $_POST['user'], $_POST['password'])) {
//connect to mysql and select database
$dbhost = ****
$dbuser = ****
$dbpass = ****
$db_name = ****
$tbl_name = ****
$connection = new mysqli($dbhost, $dbuser, $dbpass,$db_name);
//create the query
$query = "INSERT INTO $tbl_name
(title, name, surname, addressone, addresstwo, city,
postcode, phone, email, username, password)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$statement = $connection->prepare($query);
$statement->execute();
$addcottageOutcomeMessage = 'Customer Added';
switch($statement->errno)
{
case 0:
$addcottageComplete = true;
$addcottageOutcomeMessage = "Customer " . htmlspecialchars($_POST['name']) . " added";
break;
default:
$addcottageComplete = true;
$addcottageOutcomeMessage = $statement->error;
}
echo $addcottageOutcomeMessage;
include 'index.html';
$statement->close();
$connection->close();
} else {
echo 'Missing input.';
}
?>