Jump to content

HTML/PHP Web Form

- - - - -

  • Please log in to reply
2 replies to this topic

#1
chezzy62

chezzy62

    Newbie

  • Members
  • Pip
  • 1 posts
Hello everyone!

I had a question about an HTML form on a website. I am helping someone modify a website, and move it to a new server, and I ran into a little speed-bump.

https://www.heavenly...J03&stateAbb=NJ

On this page, there is a very long web form, with a lot of options. I want to copy the exact form. But I don't really know where to go from there. I would like to have it so that when a user submits their order, and presses continue, their order information is sent to my email address.

This is what the email looks like when it is sent:

ON-LINE ORDER
For Heavenly Ham - Lawrenceville, NJ (NJ03)

ORDERED BY:
Name
Address
City, State Zip
Phone Number

EMAIL ADDRESS: abc@123.com
ORDER NUMBER: 198632
ORDER DATE: 12/22/2010 3:38:45 PM

PICK-UP / DELIVERY: Pick-up
PICK-UP DATE / TIME: 12/23/2010 3:30 PM

PRODUCT: Half Ham(7-9 lbs)
QUANTITY: 3
UNIT PRICE: $47.99-$61.99


PRODUCT: Boneless Smoked Turkey(3-4 lbs)
QUANTITY: 1
UNIT PRICE: $28.99-$39.99


NUMBER OF PRODUCTS: 4


How would I go about implementing this function? As far as I've read, I believe a form method = post would work well. However, I don't know where to go from there. Maybe I could make a custom php file?

Any help would be greatly appreciated. :)

Thank you!
Josh.

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
  • Location:Vancouver, Eh! Cleverness: 200
So you are writing the PHP portion from scratch?

When a form submits data, it sends a POST request to the PHP script which accepts it through the $_POST variable, if for example you have an input form named "lastname" it would be accessible through $_POST['lastname'].

You can actually set the form's action to a test script, such as this:
<html>
<body>
<pre>
<?php print_r($_POST); ?>
</pre>
</body>
</html>
That will print out all of what PHP knows from the form's data, so you can get a better idea of the structure of the elements (such as select box, radio buttons etc.), it could help to also test minor forms of your own, to see what PHP will produce out of them in the $_POST array.

Once you move from there, the mail() function in PHP can send the contents of the email you create out of the POST data, there are many tutorials online, including some on the PHP manual for mail()
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
grisha

grisha

    Learning Programmer

  • Members
  • PipPipPip
  • 35 posts
If the form isn't generated by a script just Ctrl+C, Ctrl+V the HTML code.
Set the action attribute of the form to the new location.
In your PHP script fetch everything that's in the $_POST table. Filter it to avoid XSS.
Get the shipment data from fields like $_POST['RtxtLastName'] and remove those fields from the $_POST table. Put it to a string.
Run foreach on the $_POST table use some regular expressions, move the data from the fields to the output string.
Use mail() to send the string.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users