Topic: PHP Order Form - Simple PHP Help Needed

Hi guys,

I am working on a website and need to include a PHP Order Form for our existing customers. It is a much cleaner option than installing osCommerce or anything like that - they already know the products they will be buying so need a quick, easy ordering process.

Heres what it looks like at the minute:

http://www.yorkesofdundee.co.uk/ORDERFORM/form.php

I would now like to add two more features to the order form:

"Desired Delivery Date" : This can be a simple text box where customer enters date, or if someone is willing I think a drop down menu with the next 14 days dates included would be good (I will edit it each day to add the next day on...)

"Special Comments About Your Order" : This is just a large enough text box so that customers can say special requests - i.e. Please deliver between 2-3pm, or Bacon is to be frozen prior to delivery.

Here is a .zip file with the 5 files included, it is relatively straight forward cosing so far, i just dont know how to add extra bits in to it.

http://www.yorkesofdundee.co.uk/dw_orderform.zip

Thanks guys, any input would be appreciated,
Will

Re: PHP Order Form - Simple PHP Help Needed

In form.php, right above the line //Sales Tax add this code:

// Custom Desired Delivery Date
    $class = ($class == 'even')? 'odd': 'even';
  echo '<tr class="' . $class . '">
    <td>Desired Delivery Date</td>
    <td colspan="2"> </td>
    <td class="lbl"><select name="del_date" tabindex="' . ($num_products + 2) . '">';

    $day = 30;
    $newTime = 0;
  
  // firstDate is how many days in advance you want the first delivery date
  // showDates is how many days after firstDate you want to show
  $firstDate = 1;
  $showDates = 14;
  
  for ($x=$firstDate;$x<=$showDates;$x++) {
      $newTime = mktime(0, 0, 0, date("m")  , date("d")+$x, date("Y"));
      echo "<option>".date("F d, Y", $newTime)."</option>";
  }
  echo '</select></td></tr>';

Then look for "Enter Your Email Address" and find the </tr> tag after that. Add this row in...

  <tr class="<?php echo $class = ($class == 'even')? 'odd': 'even'; ?>">
   <td colspan="1">Comments</td>
   <td colspan="3" class="lbl"><textarea name="comments" rows="5" cols="30" tabindex="<?php echo ($num_products + 5) ?>"></textarea></td>
  </tr>

That should get your page looking right for the new fields, so all you have to do is add it to the display and email in order.php

Find this code:

$msg .= "Grand Total: $" . $_POST['grand_tot'] . "\n\n";

and under it delete everything and replace with this:

$msg .= "Desired Delivery Date: " . $_POST['del_date'] . "\n\n";
$msg .= "Comments:\n" . $_POST['comments'];
mail($to_address, $subject, $msg, $from);
?>
 
</table>
<p>Desired Delivery Date:<BR><?php echo $_POST['del_date'];?></p>
<p>Comments:<BR><?php echo $_POST['comments'];?></p>
<p>Thank you for your order.</p>
</body>
</html>

That should add it to your email and the display. Oh, it automatically calculates the next 14 dates too so you don't have to edit it every day.

I have a working copy locally I can send if something doesnt go right in the changes but I think that's it.
Andrew

Re: PHP Order Form - Simple PHP Help Needed

Wow! Thanks for all the effort you put into this for me. I really appreciate it, the code works perfectly smile Now I just have to add about 50 products to the list lol. Thanks again Andrew

4 (edited by quaker 2006-04-01 17:25)

Re: PHP Order Form - Simple PHP Help Needed

sweet work!
i have mod it a bit to work with my theme i took out the link to the css and left it to the style of the site. just added a few line from the old css to the new one.
it was easy to intergrate into my site with this code
to pull the header and footer
http://nalan.org/store.php

<?php

define('PUN_ROOT', './');
define('PUN_QUIET_VISIT', 1);
require PUN_ROOT.'include/common.php';
//if ($pun_user['g_read_board'] == '0')                         <!--remove the // for members only -->
//    message($lang_common['No view']);            <!--remove the // for members only -->

//Hide contest from Guest                                             
//if ($pun_user['is_guest'])                                            <!--remove the // for members only -->
//   message($lang_common['No permission']);               <!--remove the // for members only -->

//Set the page title here
$page_title = pun_htmlspecialchars($pun_config['o_board_title']) . ' / Chat';
define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';
require PUN_ROOT.'include/parser.php';

?>
put your body here and it will work

<?php

require PUN_ROOT.'footer.php';

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

Re: PHP Order Form - Simple PHP Help Needed

how can i added images to the product?

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

Re: PHP Order Form - Simple PHP Help Needed

I remember thinking extra options shouldn't be too hard so I'll work somethin out next week for images (and maybe a hyperlink to product info?) if there's no answer by then ... great work on modding it! Very handy!

-Andrew

7 (edited by quaker 2006-04-01 20:00)

Re: PHP Order Form - Simple PHP Help Needed

im going to repost all the files even with the style sheet if that is ok?

i think that it really need a plugin admin mod to set the array of products.
im not good and writing that stuff..lol.

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

8 (edited by quaker 2006-04-01 20:45)

Re: PHP Order Form - Simple PHP Help Needed

in the email
i got was like this
Order submitted by test@test.org

1 of Brooke Photo  for $ 12.50
1 of Widget DX  for $ 18.00
1 of Super Widget LX  for $ 24.99

Sub Total: $55.49
Shipping: $5.00
Sales Tax: $4.44
-----------------------------------------
Grand Total: $64.93Desired Delivery Date: April 02, 2006

so i added a
$msg .= "Grand Total: $" . $_POST['grand_tot'];
$msg .= "\n"; to give me a space
$msg .= "Desired Delivery Date: " . $_POST['del_date'] . "\n\n";
$msg .= "Comments:\n" . $_POST['comments'];


this is output!

Order submitted by test@test.org
12 of Brooke Photo  for $ 150.00

Sub Total: $150.00
Shipping: $5.00
Sales Tax: $12.00
-----------------------------------------
Grand Total: $167.00
Desired Delivery Date: April 02, 2006

Comments:
12345

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

Re: PHP Order Form - Simple PHP Help Needed

Cool to see some others are using the order form smile I do have a few more ideas for it so I hope I can come back here again in future to get a little bit more assisstance big_smile I just need to work out exactly how I need the form to operate.

10

Re: PHP Order Form - Simple PHP Help Needed

i would like to know how can i send the output of the order form to paypal to be processed

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

Re: PHP Order Form - Simple PHP Help Needed

checkout http://www.yorkesofdundee.co.uk/ORDERFORM/ or the index.html of the download and it gives you code to put into a PayPal button in place of the amount field. That's probably the easiest ... add a link on the submit page that says "Pay Now for quickest results, or we will email you a bill" and have the PayPal button show up there.

Re: PHP Order Form - Simple PHP Help Needed

quaker wrote:

i would like to know how can i send the output of the order form to paypal to be processed

Personally, I'd be in way over my head doing this, but Zend's tutorial on this might help you.

Looking for a certain modification for your forum? Please take a look here before posting.

13

Re: PHP Order Form - Simple PHP Help Needed

can i tbe simply modified ? i really dont understand..hahaha....

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

Re: PHP Order Form - Simple PHP Help Needed

suggestion: have it update someones user status/rank on a punbb installation once they submit an order or an order is confirmed. could add support to the purchase and open up a hidden support forum for customers.(disregard if it's already in there, i didn't read/test out the script)

~James
FluxBB - Less is more

15

Re: PHP Order Form - Simple PHP Help Needed

well the basic idea is to get the order form working first.
and sometype of ap_mod to add products then send it to paypal for chceck out and processing!

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

Re: PHP Order Form - Simple PHP Help Needed

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but23.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
<img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1">
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHZwYJKoZIhvcNAQcEoIIHWDCCB1QCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYB7QI5svPefuEnFP+UKQDeQFx5dhh6nUJ55+m4IgGO5hbaoVTitTW2MY+xBfLqtGWSf6XF9lFzW256i50H/MhMQV/FikO/SckdTFH/QfinDv0a+bRtm4YQA2q+rbTQv8wkz9uHryRx1S/qiPhEdnAGIS714Hp2hehMbbcCNV+00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G7BgNVHSMEgbMwgbCAFJaffLvGbxe9WT9S1wob7BDWZJRroYGUpIGRMIGOMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxFDASBgNVBAoTC1BheVBhbCBJbmMuMRMwEQYDVQQLFApsaXZlX2NlcnRzMREwDwYDVQQDFAhsaXZlX2FwaTEcMBoGCSqGSIb3DQEJARYNcmVAcGF5cGFsLmNvbYIBADAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAIFfOlaagFrl71+jq6OKidbWFSE+Q4FqROvdgIONth+8kSK//Y/4ihuE4Ymvzn5ceE3S/iBSQQMjyvb+s2TWbQYDwcp129OPIbD9epdr4tJOUNiSojw7BHwYRiPh58S1xGlFgHFXwrEBb3dgNbMUa+u4qectsMAXpVHnD9wIyfmHMYIBmjCCAZYCAQEwgZQwgY4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBAMUCGxpdmVfYXBpMRwwGgYJKoZIhvcNAQkBFg1yZUBwYXlwYWwuY29tAgEAMAkGBSsOAwIaBQCgXTAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0wNjA0MDYxMzU0MjdaMCMGCSqGSIb3DQEJBDEWBBR1i+650sXdVvjA6zmWotD4iuIREjANBgkqhkiG9w0BAQEFAASBgJlcx0SqGNBI+CncrFXtMpcINGcwCCuqQgibUqjvx7gUOnqJMSSY4SbWGA3RsRd67DjyZim+P0KCg/sfoaPyakkmF4y4sRhmTj3F0B8TEsviwjpcaUrRkeRLQxxpPS35rb3oom94dcxfZ4mapUo3YZgibDFULUgP4xdf4gUQjTl7-----END PKCS7-----
">
</form>

That is a button I created using PayPal. Where in the code do I put my grand total amount?

<input type="hidden" name="amount" value="<?php echo $grand_tot ?>">

Thanks

Re: PHP Order Form - Simple PHP Help Needed

Can't use an encrypted button with PayPal because it encrypts the amount.

Make a button and put in a set price like 999. Choose non-encrypted you should get a line that is exactly the same as the grand total code line but has 999 for the value.

Re: PHP Order Form - Simple PHP Help Needed

When an order is emailed to me, it isn't stating the shipping method the user selected. How can I change this?

Even though I typed in product codes for my items they are not being shown on form.php, order.php, or in the email sent to me confirming an order. How can I change this?

Thanks (again)

Re: PHP Order Form - Simple PHP Help Needed

andrewteg wrote:

Can't use an encrypted button with PayPal because it encrypts the amount.

Make a button and put in a set price like 999. Choose non-encrypted you should get a line that is exactly the same as the grand total code line but has 999 for the value.

Thank you, makes sense now big_smile

Re: PHP Order Form - Simple PHP Help Needed

downliner wrote:

When an order is emailed to me, it isn't stating the shipping method the user selected. How can I change this?

Even though I typed in product codes for my items they are not being shown on form.php, order.php, or in the email sent to me confirming an order. How can I change this?

Thanks (again)

These questions may have been overlooked by people as I posted again quickly after to thank andrewteg. Anyone able to offer some insight? Thanks! big_smile

Re: PHP Order Form - Simple PHP Help Needed

Sounds like an error in order_fns.php where you setup the products and shipping arrays... go back to the default and try that and see if it works with the defaults. This is the default from the beginning of the file to the line "No need to edit below this line" if you need it.

<?php
// array elements: product code, product name, unit price
// product code should contain no spaces, only letters, numbers
// and underscores (first character should not be number)
$products = array (
  array ("wd_001", "Widget 001", 12.50),
  array ("wd_dx", "Widget DX", 18),
  array ("sp_wd_lx", "Super Widget LX", 24.99)
);

// optional: sales tax and shipping options, i.e., if you do not include the variables 
// the relevant portions of the form will not be generated and code will still work fine
$state = "California";
$cur_sales_tax = .075;    // state sales tax 

// shipping options: radio button text, value
// (quantity ordered not taken into account in this form)
$ship_options = array (
  array ("Pick up locally", 0),
  array ("UPS Ground", 5),
  array ("Fed Ex Overnight", 20)
);

// No need to edit below this line 
?>

22 (edited by quaker 2006-04-06 21:25)

Re: PHP Order Form - Simple PHP Help Needed

ok i got an ap_product manager designed and it list in the store front.. so there are a few little issue left. on how to remove items and such!
so far it coming along good..
im looking for people who can help with the design.
now working out the bugs of adding products with photos...hehe..
need a paypal guru!
HIT ME UP!

http://nalan.org/store.php

http://www.nalan.org/uploaded/store.png

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

Re: PHP Order Form - Simple PHP Help Needed

@ andrewteg: I tried the original code but it still isnt showing my product codes anywhere. If I zip my files would you mind taking a look for me? If someone has the original files maybe they can confirm that when an email is sent it is showing them the product codes...?

@ quaker: The mod is looking awesome dude, keep it up. I didn't expect anyone to mod the order form at all, I just needed help getting it to function correctly lol. This could make life a lot easier instead of having to write the damn arrays into php over and over big_smile

24 (edited by quaker 2006-04-07 15:30)

Re: PHP Order Form - Simple PHP Help Needed

downliner.. dude... that what im trying to do... kill the array in the file... who want to edit php files to add products.. a simple click here and there...
i think by monday it will be completed.. with ap_mod and working..
NEED PAYPAL API GURU.... THAT THE NEXT MISSION..... PAYPALLLLLLLLLLLLLLLLLLLLLL..



<!-- in the final stages before release is out! still no paypal API.. one little bug.. product name not listed. --!>

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

25 (edited by Dr.Jeckyl 2006-04-09 22:01)

Re: PHP Order Form - Simple PHP Help Needed

i forgot how cool my skin looked. big_smile

can you link me where to get that Evasion skin please?

ps: i replied to your post at punres about my skin.

i hope you guys port this over to 1.3 when it comes out.

~James
FluxBB - Less is more