Jump to content

Help me make my code and page pretty!!!!


gathos

Recommended Posts

ok so here is the page i need help with

http://www.typh.ca/phpcalctest.php now what i need is to HIDE (or something) the sentence that contains the estimate until the user clicks submit.

i have one condition - it has to be simple (cause i'm an idiot.)

any ways heres my code:

<html>
<head>
<title>Price calculator</title>
</head>
<body>

<?php
$length = $_POST["length"];
$height = $_POST["height"];
$price = $_POST["price"];
$total = $_POST["total"];
?>

<p><img src="Phil/images/b_spiderman.gif" height="100"></p>
<form method="post" action="<?php echo $PHP_SELF;?>">

  <p>Length:
    <input type="text" name="length" id="length">
    <br>
    Height:
    <input type="text" name="height" id="height">
  </p>
  <p>
    <input type="submit" value="submit" name="submit">
  </p>
</form>

<?
// set the PRICE to the square footage cost of the inserts
$price = 0.25;

$total = $length * $height * $price;
echo "Your inserts are an estimated cost of $ $total";
?> 
</body>

Please help me, i'm hitting a brick wall and my brain is starting to detach. :(

Link to comment
Share on other sites

<html>
<head>
<title>Price calculator</title>
</head>
<body>

<?php
$length = $_POST["length"];
$height = $_POST["height"];
$price = $_POST["price"];
$total = $_POST["total"];
?>

<p><img src="Phil/images/b_spiderman.gif" height="100"></p>
<form method="post" action="<?php echo $PHP_SELF;?>">

  <p>Length:
    <input type="text" name="length" id="length">
    <br>
    Height:
    <input type="text" name="height" id="height">
  </p>
  <p>
    <input type="submit" value="submit" name="submit">
  </p>
</form>

<?php
if(!empty($_POST)){
// set the PRICE to the square footage cost of the inserts
$price = 0.25;

$total = $length * $height * $price;
echo "Your inserts are an estimated cost of $ $total";
}
?> 
</body>

Link to comment
Share on other sites

Or you could be more specific and use...

 

<html>
<head>
<title>Price calculator</title>
</head>
<body>

<?php
$length = $_POST["length"];
$height = $_POST["height"];
$price = $_POST["price"];
$total = $_POST["total"];
?>

<p><img src="Phil/images/b_spiderman.gif" height="100"></p>
<form method="post" action="<?php echo $PHP_SELF;?>">

  <p>Length:
    <input type="text" name="length" id="length">
    <br>
    Height:
    <input type="text" name="height" id="height">
  </p>
  <p>
    <input type="submit" value="submit" name="submit">
  </p>
</form>

<?php
if(strip_tags($_POST['length']) && strip_tags($_POST['height']) && strip_tags($_POST['submit'])){
//NOTE THAT $_POST['length'] OR $_POST['height'] IS FROM THE INPUT FIELDS NAME 

//if u use cooldudes and ur using more than one form on a page
//you'll run into problems

// set the PRICE to the square footage cost of the inserts
$price = 0.25;

$total = $length * $height * $price;
echo "Your inserts are an estimated cost of $ $total";
}
?> 
</body>

Link to comment
Share on other sites

how does verifying if strip tags works on variables do anything in your case???

 

Also fyi you aren't doing anything productive with those strip_tags

 

also

$PHP_SELF isn't good to use because its a registered global of $_SERVER['PHP_SELF']

 

sorry I'm a super noob, I have no idea what to use instead if i remove the fist section of php code:

<?php
$length = $_POST["length"];
$height = $_POST["height"];
$price = $_POST["price"];
$total = $_POST["total"];
?>

 

the calculator stops working, i'm not sure what else to use instead.

 

as for the global variable again i have no idea what to use instead.

 

I basically thought myself a freaking genious to stumble upon this. (and i demostrate of how much of a genious by my spelling)

Link to comment
Share on other sites

thanks for taking time out of your day to help

here is the code - it neded sixteenth added so i did, but it doesn't work.

<html>
<head>
<title>Price calculator</title>
</head>
<body>


<?php
$width = $_POST["width"];
$width = $_POST["width16"];
$height = $_POST["height"];
$height16 = $_POST["height16"];
$price = "0.25";
$totalheight = $_POST["totalheight"];
$totalwidth = $_POST["totalwidth"];
$total = $_POST["total"];
?>

<p><img src="Phil/images/b_spiderman.gif" height="100"></p>
<form method="post"> 
         <p>
           <input type="text" name="height">
           <select name="height16" id="height16">
	   <option value="0">Choose sixteenth</option>
             <option value="0.0625">1/16</option>
             <option value="0.125">1/8</option>
             <option value="0.1875">3/16</option>
             <option value="0.250">1/4</option>
             <option value="0.3125">5/16</option>
             <option value="0.375">3/8</option>
             <option value="0.4375">7/16</option>
             <option value="0.500">1/2</option>
             <option value="0.5625">9/16</option>
             <option value="0.625">5/8</option>
             <option value="0.6875">11/16</option>
             <option value="0.750">3/4</option>
             <option value="0.8125">13/16</option>
             <option value="0.875">7/8</option>
             <option value="0.9375">15/16</option>
           </select>
           <br>
             <input type="text" name="width">
             <select name="width16" id="width16">
		 <option value="0">Choose sixteenth</option>
             <option value="0.0625">1/16</option>
             <option value="0.125">1/8</option>
             <option value="0.1875">3/16</option>
             <option value="0.250">1/4</option>
             <option value="0.3125">5/16</option>
             <option value="0.375">3/8</option>
             <option value="0.4375">7/16</option>
             <option value="0.500">1/2</option>
             <option value="0.5625">9/16</option>
             <option value="0.625">5/8</option>
             <option value="0.6875">11/16</option>
             <option value="0.750">3/4</option>
             <option value="0.8125">13/16</option>
             <option value="0.875">7/8</option>
             <option value="0.9375">15/16</option>
             </select>
         </p>
         <p><br>
             <input type="submit" name="submit" value="Calculate"> 
         </p>
</form>

<?
if(!empty($_POST)){

// set the PRICE to the square footage cost of the inserts
$price = 0.25;
$totalwidth = $width + $width16;
$totallength = $length + $length16;
$total = $totalwidth * $totalheight * $price;
echo "Your inserts are an estimated cost of $ $total";
}
?> 
</body>

 

so i get a result of $0 when it echo's price

 

and FYI i would take classes but i can't because i work 2 jobs and help my wife take care of my baby, since she's to sick to look after him all the time, and i can't afford to spend any money on classes.

but you didn't know that.

 

and THIS isn't my job i was joking, i work on stained glass, i told my boss i can do html - hell everyone does html, but he want's it all. asp java php mysql css ecommerce, and is willing to pay for me to learn on my own but not willing to pay for classes. so thank you I really apreaciate your time, but if you feel that I should go to classes instead of asking for help, fine don't answer.

Link to comment
Share on other sites

look coments

<html>
<head>
<title>Price calculator</title>
</head>
<body>


<?php
$width = $_POST["width"];
$width16 = $_POST["width16"]; // add 16 to variable name
$height = $_POST["height"];
$height16 = $_POST["height16"];
$price = "0.25";
//$totalheight = $_POST["totalheight"]; remove this line
//$totalwidth = $_POST["totalwidth"];
//$total = $_POST["total"];
?>

<p><img src="Phil/images/b_spiderman.gif" height="100"></p>
<form method="post"> 
         <p>
           <input type="text" name="height">
           <select name="height16" id="height16">





   <option value="0">Choose sixteenth</option>
             <option value="0.0625">1/16</option>
             <option value="0.125">1/8</option>
             <option value="0.1875">3/16</option>
             <option value="0.250">1/4</option>
             <option value="0.3125">5/16</option>
             <option value="0.375">3/8</option>
             <option value="0.4375">7/16</option>
             <option value="0.500">1/2</option>
             <option value="0.5625">9/16</option>
             <option value="0.625">5/8</option>
             <option value="0.6875">11/16</option>
             <option value="0.750">3/4</option>
             <option value="0.8125">13/16</option>
             <option value="0.875">7/8</option>
             <option value="0.9375">15/16</option>
           </select>
           <br>
             <input type="text" name="width">
             <select name="width16" id="width16">







<option value="0">Choose sixteenth</option>
             <option value="0.0625">1/16</option>
             <option value="0.125">1/8</option>
             <option value="0.1875">3/16</option>
             <option value="0.250">1/4</option>
             <option value="0.3125">5/16</option>
             <option value="0.375">3/8</option>
             <option value="0.4375">7/16</option>
             <option value="0.500">1/2</option>
             <option value="0.5625">9/16</option>
             <option value="0.625">5/8</option>
             <option value="0.6875">11/16</option>
             <option value="0.750">3/4</option>
             <option value="0.8125">13/16</option>
             <option value="0.875">7/8</option>
             <option value="0.9375">15/16</option>
             </select>
         </p>
         <p><br>
             <input type="submit" name="submit" value="Calculate"> 
         </p>
</form>

<?
if(!empty($_POST)){

// set the PRICE to the square footage cost of the inserts
$price = 0.25;
$totalwidth = $width + $width16;
$totalheight = $height + $height16;// the variable $lenght isn't setup jet
$total = $totalwidth * $totalheight * $price;
echo "Your inserts are an estimated cost of $ $total";
}
?> 
</body>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.