Jump to content

Newb post/value form


Skulks

Recommended Posts

 

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");

?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/208035-newb-postvalue-form/
Share on other sites

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/208035-newb-postvalue-form/#findComment-1088132
Share on other sites

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.

 

Link to comment
https://forums.phpfreaks.com/topic/208035-newb-postvalue-form/#findComment-1088157
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.