Jump to content

Recommended Posts

Hi,

 

I am currently in the process of making an order form although I have come across a small problem. In the order form, you have the option to select which product you are ordering from a drown menu. The value of each item of the menu is that name of the product. This value is then sent to a processing page which emails it to me and the user is then taking to a page in which they can pay for the product using paypal. However, I can find no way of the processing page sending me the price as well. The only way I can think of doing this is making the value for each drop down item the price of the product, but this would mean I do not get to see what the product is called.

 

Your help would be greatly appreciated.

 

 

Many Thanks,

Chris

Link to comment
https://forums.phpfreaks.com/topic/64547-using-a-drop-down-menu-to-set-the-price/
Share on other sites

If everything is stored in a database, why not do another quick query on the page that emails you the information and pull the price and everything relevant from there.  All that needs to be passed from the form page is the amount ordered and the ID/name of the product.

 

Otherwise, use hidden input fields.

Without knowing more about the setup it is impossible to give an appropriate solution. For example, if the products and prices are in a database, your processing page could do a lookup of the price. However, if you are hard-coding all the products and prices, you could make the value something like this "productname|productprice". Then the processing page can split the value based upon the pipe character.

Let's assume the field name is "product" and the value selected is "Claw Hammer|9.95"

 

<?php

//Convert the "product" value to an array, split on the "|" character
$prod_detail = explode('|', $_POST['product']);

echo 'Product name: ' . $prod_detail[0];
echo '<br>Product price: ' . $prod_detail[1];

//Output:
//Product name: Claw Hammer
//Product price: 9.95

?>

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.