Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7879105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:49:43+00:00 2026-06-03T03:49:43+00:00

I have php file with form which the user need to enter three parameters

  • 0

I have php file with form which the user need to enter three parameters width and height and shape Tringle or rectangle.
in my first line code of php I try to read the width and height parameters and in the end of lines code php I try to read the shape Tringle or rectangle parameter and according this parameters to calculated the area.
Thx for any healp.

 <h2>OOP Class Demo</h2>
<p>
Please enter two numbers to calculated the area of rectangle or tringle and press submit...
<p>
<form method="post" action="demo.php">
<br>width.1 <input type=text name=num_a>
<br>height.2 <input type=text name=num_b>
<br><input type="radio" name="shape" value="Rectangle" /> Rectangle
<br><input type="radio" name="shape" value="Tringle" /> Tringle
<br><input type=submit>
</form>

<?php

  echo("<br>");
  if(isset($_POST['submit']))
   {echo "THERE is submit.!"; 
    Class Rectangle {

    //Declare the attributes:
    public $width = $_POST['width'];
    public $height = $_POST['height'];
    protected static $formula = 0;

//Method to set the dimensions.
    Function create_formula() {
        self :: $formula = $this->width * $this->height;
    }

    //Method to set the dimensions.
    Function set_size($w = 0, $h = 0) {
            $this->width = $w;
            $this->height = $h;
            $this->create_formula();
    }

    //Method to calculate and return the area.
    function get_area() {
            return (self::$formula);
            }
    }

    Class Triangle extends Rectangle{
        Function create_formula() {
            self :: $formula = ($this->width * $this->height)/2;
        }
    }

    if (!$_POST['shape']){echo('your choice is: '.$_POST['shape']);}
    // create object of rectangle and calculate it is area
    $rect = new Rectangle ();
    echo ($rect->get_area()."<br />");

    // create object of tringle and calculate it is area by extends
    $tri = new Triangle ();
    echo $tri->get_area();
    }

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:49:44+00:00Added an answer on June 3, 2026 at 3:49 am

    Your html control name is different than php variable names.

    <br>width.1 <input type=text name=num_a>
    <br>height.2 <input type=text name=num_b>
    

    and your php

    public $width = $_POST['width'];
    public $height = $_POST['height'];
    

    It should be

    <br>width.1 <input type=text name='width'>
    <br>height.2 <input type=text name='height'>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php file that contains a form (which contains 2 input boxes
i have a form in which user can upload 100 mb file which results
I have a small form in which the user uploads a file. What I
I have a PHP form which includes a file being uploaded upon submit. As
I am generating a rss(xml) output form a php file. I have got a
So, i have this form in a php file and i want it to
I have an upload box... <form action=upload_file.php method=post enctype=multipart/form-data><BR> <label for=file>Filename:</label><BR> <input type=file name=file
I have a PHP validate statement for a file upload on a HTML form.
I have this HTML: <form action='uploadhandle.php' method='POST' enctype=multipart/form-data> <input type='file' class='fileinput' id='photo1' name='photo1'> <input
I have a php file which I will be using as exclusively as an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.