Good Day po mga sir mam . nanawagan po ako sa ma mai alam jan sa OOP PHP D ko natalga makita at nahihirapan na ako san problema haha.
newbie lang kasi .. di ko kasi makit ayung quantity tsaka price after ko mag enter ng quantity .. zz eto po code ko ..
index.php
output.php
otep.class.php
SANA po matlungan nyo ako . TIA.
#rp
newbie lang kasi .. di ko kasi makit ayung quantity tsaka price after ko mag enter ng quantity .. zz eto po code ko ..
index.php
Code:
<?php
include('Class/otep.class.php');
session_start();
$bb = 65.50;
$milo = 79.80;
$nido = 89.50;
$alpine = 5.50;
$prices = "";
if (isset($_POST['submit'])){
if ($_POST['name'] == "BEAR BRAND" || $_POST['name'] == "MILO" || $_POST['name'] == "NIDO"|| $_POST['name'] == "ALPINE"){
$_SESSION['name'] = $_POST['name'];
$_SESSION['prices'] = $prices;
header("location: output.php");
}
}
?>
<html>
<head>
<title>Otep</title>
</head>
<body>
<h3>Simple POS Otep</h3>
<form action ="" method="POST">
<input type="text" name="name" placeholder="Enter Product"><input type="submit" name="submit" value="Submit">
</form>
<?php
$POSOtep = new POSOtep();
if (empty($POST['name'])){
}else{
if (isset($_POST['submit'])) {
if ($_POST['name'] == "BEAR BRAND") {
$POSOtep->setbrandname("BEAR BRAND");
$POSOtep->setprice($bb);
$prices = $bb;
}else if ($_POST['name'] == "MILO"){
$POSOtep->setbrandname("MILO");
$POSOtep->setprice($milo);
$prices = $milo;
}else if ($_POST['name'] == "NIDO"){
$POSOtep->setbrandname("NIDO");
$POSOtep->setprice($nido);
$prices = $nido;
}else if ($_POST['name'] == "ALPINE"){
$POSOtep->setbrandname("ALPINE");
$POSOtep->setprice($alpine);
$prices = $alpine;
}else{
echo "Error!";
}
}
}
?>
</body>
</html>
output.php
Code:
<?php
include('Class/otep.class.php');
session_start();
$bb = 65.50;
$milo = 79.80;
$nido = 89.50;
$alpine = 5.50;
$prices = "";
if (isset($_POST['submit'])){
if ($_POST['name'] == "BEAR BRAND" || $_POST['name'] == "MILO" || $_POST['name'] == "NIDO"|| $_POST['name'] == "ALPINE"){
$_SESSION['name'] = $_POST['name'];
$_SESSION['prices'] = $prices;
header("location: output.php");
}
}
?>
<html>
<head>
<title>program - Otep</title>
</head>
<body>
<h3>Simple POS Otep</h3>
<form action ="" method="POST">
<input type="text" name="name" placeholder="Enter Product"><input type="submit" name="submit" value="Submit">
</form>
<?php
$POSOtep = new POSOtep();
if (empty($POST['name'])){
}else{
if (isset($_POST['submit'])) {
if ($_POST['name'] == "BEAR BRAND") {
$POSOtep->setbrandname("BEAR BRAND");
$POSOtep->setprice($bb);
$prices = $bb;
}else if ($_POST['name'] == "MILO"){
$POSOtep->setbrandname("MILO");
$POSOtep->setprice($milo);
$prices = $milo;
}else if ($_POST['name'] == "NIDO"){
$POSOtep->setbrandname("NIDO");
$POSOtep->setprice($nido);
$prices = $nido;
}else if ($_POST['name'] == "ALPINE"){
$POSOtep->setbrandname("ALPINE");
$POSOtep->setprice($alpine);
$prices = $alpine;
}else{
echo "Error!";
}
}
}
?>
</body>
</html>
otep.class.php
Code:
<?php
class POSOtep {
public $price;
public $quantity;
public $brandname;
public $payment;
public $needpay;
public $total;
public function setbrandname($brandnames){
$this->brandname = $brandnames;
}
public function setprice($prices){
$this->price = $prices;
}
public function setquantity($quantitys){
$this->quantity = $quantitys;
$this->needpay = ($this->price * $this->quantity);
}
public function setpayment($payments){
$this->payment = $payments;
$this->total = ($this->payment - ($this->price * $this->quantity));
}
public function displayProduct(){
echo "<b>SIMPLE POS SYSTEM - OTEP</b>" . "<p></p>";
return "Name: " . $this->brandname . "<br>" . "Price: " . $this->price . "<br>";
}
public function retQty(){
return $this->quantity;
}
public function displayPayment(){
return $this->brandname . " : " . $this->needpay = ($this->price * $this->quantity) . "<br>";
}
public function displayAll(){
return $this->brandname . " : " . $this->total = ($this->payment - ($this->price * $this->quantity)) . "<br>";
}
}
?>
SANA po matlungan nyo ako . TIA.
#rp