gathos Posted February 19, 2008 Share Posted February 19, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/91993-help-me-make-my-code-and-page-pretty/ Share on other sites More sharing options...
cooldude832 Posted February 19, 2008 Share Posted February 19, 2008 <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> Quote Link to comment https://forums.phpfreaks.com/topic/91993-help-me-make-my-code-and-page-pretty/#findComment-471163 Share on other sites More sharing options...
ILYAS415 Posted February 19, 2008 Share Posted February 19, 2008 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> Quote Link to comment https://forums.phpfreaks.com/topic/91993-help-me-make-my-code-and-page-pretty/#findComment-471167 Share on other sites More sharing options...
gathos Posted February 19, 2008 Author Share Posted February 19, 2008 THANK YOU SO MUCH!!!! now i can keep my job pretending i know what i'm doing !!!!! lol thanks again Quote Link to comment https://forums.phpfreaks.com/topic/91993-help-me-make-my-code-and-page-pretty/#findComment-471170 Share on other sites More sharing options...
cooldude832 Posted February 19, 2008 Share Posted February 19, 2008 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'] Quote Link to comment https://forums.phpfreaks.com/topic/91993-help-me-make-my-code-and-page-pretty/#findComment-471173 Share on other sites More sharing options...
gathos Posted February 19, 2008 Author Share Posted February 19, 2008 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) Quote Link to comment https://forums.phpfreaks.com/topic/91993-help-me-make-my-code-and-page-pretty/#findComment-471185 Share on other sites More sharing options...
cooldude832 Posted February 19, 2008 Share Posted February 19, 2008 helps if we see your whole script. Fyi if you have a job in php maybe you should consider taking classes Quote Link to comment https://forums.phpfreaks.com/topic/91993-help-me-make-my-code-and-page-pretty/#findComment-471186 Share on other sites More sharing options...
gathos Posted February 27, 2008 Author Share Posted February 27, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/91993-help-me-make-my-code-and-page-pretty/#findComment-478267 Share on other sites More sharing options...
cooldude832 Posted February 27, 2008 Share Posted February 27, 2008 some how your last statement makes the people who helped you feel really great... Quote Link to comment https://forums.phpfreaks.com/topic/91993-help-me-make-my-code-and-page-pretty/#findComment-478275 Share on other sites More sharing options...
gathos Posted February 27, 2008 Author Share Posted February 27, 2008 sorry your right it wasn't nice, i'm just under alot of stress so again i'm sorry. Quote Link to comment https://forums.phpfreaks.com/topic/91993-help-me-make-my-code-and-page-pretty/#findComment-478285 Share on other sites More sharing options...
sasa Posted February 27, 2008 Share Posted February 27, 2008 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> Quote Link to comment https://forums.phpfreaks.com/topic/91993-help-me-make-my-code-and-page-pretty/#findComment-478319 Share on other sites More sharing options...
gathos Posted February 27, 2008 Author Share Posted February 27, 2008 thanks sasa i appreciate your help it works now Quote Link to comment https://forums.phpfreaks.com/topic/91993-help-me-make-my-code-and-page-pretty/#findComment-478427 Share on other sites More sharing options...
revraz Posted February 27, 2008 Share Posted February 27, 2008 I know they fixed your code, but I hope you saw the errors. You were adding/multipling variables that didn't exist. Quote Link to comment https://forums.phpfreaks.com/topic/91993-help-me-make-my-code-and-page-pretty/#findComment-478430 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.