bd.php
<?php
class BD
{ // start
private $mysql;
function __construct($server, $username, $password, $database)
{ // start function
$this -> mysql = new mysqli($server, $username, $password, $database);
if ($this -> mysql --> connect_errno)
{ // start if
echo "Failed to Connect to MySQL: (" . $this -> mysqli -> connect_errno . ")" . $this-> mysqli -> connect_error;
} // end if
} // end function
public function get_clients()
{ // start function
$clients = array();
$resultclient = $this -> mysqli -> query("Select * from clients");
while ($row = $resultclients -> fetch_asssoc())
{ // start while
$clients[] = array ($row ['ClientIDNumber'], $row['ClientFirstName'], $row['ClientLastName'], $row['ClientPhoneNumber'], $row['ClientCompanyName'], $row['ClientType']);
} // end while
return $clients;
} // end function
public function insertclients ($ClientIDNumber, $ClientFirstName, $ClientLastName, $ClientPhoneNumber, $ClientCompanyName, $ClientType)
{ // start function
$result = $this -> mysqli -> query ("Insert Into clients (ClientIDNumber, $ClientFirstName, $ClientLastName, $ClientCompanyName) values ('".$ClientIDNumber."', '".$ClientFirstName."', '".$ClientLastName."', '".$ClientCompanyName."')");
return $resultclient;
} // end function
} // end
?>
end of bd.php
start of data.php
<?php
$ClientIDNumber=$_POST["ClientIDNumber"];
echo "<br>"; echo $ClientIDNumber;
$ClientFirstName=$_POST["ClientFirstName"];
echo "<br>"; echo $ClientFirstName;
$ClientLastName=$_POST["ClientLastName"];
echo "<br>"; echo $ClientLastName;
$ClientPhoneNumber=$_POST["ClientPhoneNumber"];
echo "<br>"; echo $ClientPhoneNumber;
$ClientCompanyName=$_POST["ClientCompanyName"];
echo "<br>"; echo $ClientCompanyName;
$ClientType=$_POST["ClientType"];
echo "<br>"; echo $ClientType;
?>
end of data.php
start of index.php
<html>
<head>
<title>Forms</title>
</head>
<body>
<form action="data.php" method="post">
<p>Client ID Number: <input type="text" name="Client ID Number" /></p>
<p>Client First Name: <input type="text" name="Client First Name" /></p>
<p>Client Last Name: <input type="text" name="Client Last Name" /></p>
<p>Client Phone Number: <input type="text" name="Client Phone Number" /></p>
<p>Client Company Name: <input type="text" name="Client Company Name" /></p>
<p>Client Type: <input type="text" name="Client Type" /></p>
<p><input type="submit" /></p>
</form>
</body>
</html>
<?php
include "bd.php";
$tableclients = new BD('localhost', 'root', '', 'Assignment');
$clients = $bd -> get_clients();
foreach($clients as $clients)
{
echo $clients. '<br>';
}
?>
end of index.php
start of insertclient.php
<?php
include "bd.php";
include "data.php";
$tableclients = new BD('localhost', 'root', '', 'assignment');
$tableclients -> insertclients ("1", "John", "Smith", "555-555-5555", "", "Customer");
if ($result==true)
{ // start if
echo "Data Correctly Entered";
} // end if
else
{ // start else
echo "Error";
} // end else
?>
end of insert client
this is all i got and i was given the following error codes:
[ATTACH]5233[/ATTACH]
what am i doing wrong and how can i fix these errors. i still got 14 more to go 🙁
error.png