Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

[PHP] Help po sa PHP oop

JosefGrafixStudio

 
Apprentice
Advanced Member
Messages
69
Reaction score
1
Points
28
Power Stone
Reality Stone
Soul Stone
Time Stone
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
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. :help: :praise:
#rp
 
Back
Top Bottom