Skip to content

Instantly share code, notes, and snippets.

@BMU-Verlag
Last active Sep 12, 2020
Embed
What would you like to do?
<?php
include ("class_customer.php");
$newCustomer = new Customer();
if (!empty($_REQUEST['first_name']))
{
if ($_REQUEST['first_name'] != "")
{
$newCustomer->setFirstName($_REQUEST['first_name']);
}
}
if (!empty($_REQUEST['last_name']))
{
if ($_REQUEST['last_name'] != "")
{
$newCustomer->setLastName($_REQUEST['last_name']);
}
}
if (!empty($_REQUEST['street']))
{
if ($_REQUEST['street'] != "")
{
$newCustomer->setStreet($_REQUEST['street']);
}
}
if (!empty($_REQUEST['post_code']))
{
if ($_REQUEST['post_code'] != "")
{
$newCustomer->setPostCode($_REQUEST['post_code']);
}
}
if (!empty($_REQUEST['place']))
{
if ($_REQUEST['place'] != "")
{
$newCustomer->setPlace($_REQUEST['place']);
}
}
if (!empty($_REQUEST['mail']))
{
if ($_REQUEST['mail'] != "")
{
$newCustomer->setMail($_REQUEST['mail']);
}
}
if (!empty($_REQUEST['phone']))
{
if ($_REQUEST['phone'] != "")
{
$newCustomer->setPhone($_REQUEST['phone']);
}
}
if (!empty($_REQUEST['password']))
{
if ($_REQUEST['password'] != "")
{
ewCustomer-> setPassword($_REQUEST['password']);
}
}
try
{
$dbh = new PDO ("mysql:dbname=onlineshopDB; host=localhost", "user1", "abc");
$newCustomer->setCustomerNumber($dbh);
$sql = "INSERT INTO os_customers ".
"(c_first_name, c_last_name, c_street, c_post_code, c_place, c_mail, c_phone, c_password, c_customer_number) ".
"VALUES ('".
$newCustomer->getFirstName()."', '".
$newCustomer->getLastName()."', '".
$newCustomer->getStreet()."', ".
$newCustomer->getPostCode().", '".
$newCustomer->getPlace()."', '".
$newCustomer->getMail()."', ".
$newCustomer->getPhone().", '".
$newCustomer->getPassword()."', ".
$newCustomer->getCustomerNumber().");";
print $sql."<br>";
$dbh->query($sql);
$dbh = null;
}
catch(PDOException $e)
{
print $e->getMessage();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment