Skulks Posted July 17, 2010 Share Posted July 17, 2010 I’m trying to build a php post form for this page: http://sakura-yamato.com/menu.html So people can order for delivery. I know how to do post forms OK. But I need to assign a value (price) to each item. Then echo a total. Plus I need the resulting email to leave out any boxes not filled in. The main problem is I can’t seem to search down an answer on here or google. Can someone tell me the type of cmd’s I should be using. Then at least Ill have the correct keywords to search for. Soz for the newb question but I need to get this done today. This is my standard post code and use dreamweaver. Cheeers <? // Configuration Settings $SendFrom = "Contact Form <>"; $SendTo = "[email protected]"; $SubjectLine = "Contact"; $ThanksURL = "index_enquiry.html"; //confirmation page $Divider = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; // Build Message Body from Web Form Input $MsgBody = @gethostbyaddr($REMOTE_ADDR) . "\n$Divider\n"; foreach ($_POST as $Field=>$Value) $MsgBody .= "$Field: $Value\n"; $MsgBody .= $Divider . "\n" . $HTTP_USER_AGENT . "\n"; $MsgBody = htmlspecialchars($MsgBody); //make content safe // Send E-Mail and Direct Browser to Confirmation Page mail($SendTo, $SubjectLine, $MsgBody, "From: " . $SendFrom); header("Location: $ThanksURL"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/208035-newb-postvalue-form/ Share on other sites More sharing options...
Skulks Posted July 19, 2010 Author Share Posted July 19, 2010 I seem to have found code showing how I'm meant to do this and Im starting to get the hang of it. http://www.dyn-web.com/code/order_form/ Example 2 The test page I'm playing with is here: http://sakura-yamato.com/ttest/mine2.php If you go down to item 10 you can see the new item box I've added (doggy balls). It works out the new sub total fine but I cant get it to add this to the main total (floats left side) thus the resulting results page says I didn't order anything. The thing thats bugging me the most is each time it works something out the page jumps back to the top. Someone please give me a poke in the right direction. Its driving me mad. Cheers Quote Link to comment https://forums.phpfreaks.com/topic/208035-newb-postvalue-form/#findComment-1088132 Share on other sites More sharing options...
Skulks Posted July 19, 2010 Author Share Posted July 19, 2010 I'm most likely gonna cut out all the validation stuff if that makes it any easier. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/208035-newb-postvalue-form/#findComment-1088133 Share on other sites More sharing options...
Skulks Posted July 19, 2010 Author Share Posted July 19, 2010 I maybe getting my head around some of it. "Maybe" Any help on the page jumping back to the top would still be helpfull. Cheeers Quote Link to comment https://forums.phpfreaks.com/topic/208035-newb-postvalue-form/#findComment-1088151 Share on other sites More sharing options...
Kevin.Arvixe Posted July 19, 2010 Share Posted July 19, 2010 To be honest, this is a bit of a task. I can give you some suggestions to look up though... Ajax/JQuery frameworks are great at dynamically changing things like Order totals. Look into this. For the form only e-mailing what is filled in, you could do something like... foreach ($_POST as $v) { if(strlen($v) != 0) { //include in the e-mail } else { //dont include } } If I am correct, that should essentially be your syntax. Quote Link to comment https://forums.phpfreaks.com/topic/208035-newb-postvalue-form/#findComment-1088157 Share on other sites More sharing options...
Skulks Posted July 19, 2010 Author Share Posted July 19, 2010 Thanks mate. Didn't think of page refresh. i took it as some form of anchor (# at end of ulr). Now I at least have some where to go from here besides loonybin Quote Link to comment https://forums.phpfreaks.com/topic/208035-newb-postvalue-form/#findComment-1088176 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.