Jump to content

php order form: first time user


jessmolchan

Recommended Posts

Hi Everyone! I'm trying to build a simple order form. I just can't seem to get it to work. Every time I try to add the functions to get the form data, it returns an error. The php I have now is working, it's just not pulling any of the info because I can't get that to work correctly. Here is the php I'm using:

<?phpmail( "j.mandm.design@gmail.com", "Online Cookie Order",    $message, "From: $email" );/* Prepare autoresponder subject */$respond_subject = "Jersey Cookie Girl: Thank you for your order!";/* Prepare autoresponder message */$respond_message = "Thank you for your order!We look forward to discussing the details of your special event with you to ensure a unique design is achieved and your occasion is memorable. Cookie Girl takes great pride in creating beautiful and edible designs and will be in touch with you in the next 48hrs. Thank you,Nicole BorotaCookie Girlwww.jerseycookiegirl.com";/* Send the message using mail() function */mail($email, $respond_subject, $respond_message);header( "Location: [url="http://www.jerseycookiegirl.com/thankyou.shtml""]http://www.jerseycookiegirl.com/thankyou.shtml"[/url] );?>

and here is the link for the order page: http://www.jerseycookiegirl.com/order_form.shtmlAny help would be greatly appreciated. ~Jess :)

Link to comment
Share on other sites

what would be more helpful is to show us your form code and the code you were trying to use to get that data. While it's great to know what works, the questions you have pertain to what isn't working, and without seeing it, we can't really help you except to show examples.

Link to comment
Share on other sites

what would be more helpful is to show us your form code and the code you were trying to use to get that data. While it's great to know what works, the questions you have pertain to what isn't working, and without seeing it, we can't really help you except to show examples.
Hey guys, for some reason I never got the emails that told me there were replies to this post. So thank you for replying so quickly and sorry about me taking so long. Here is the form html:
<h1>cookie order form</h1><form name="order form" action="process.php" method="post"><p>Jersey Cookie Girl offers Cookie Favors, Cookie Party Platters, Cookie Bouquets and Cookie Gift Boxes.</p><h2>Cookie Girl Cookie Favors:</h2> <p>Custom cookie prices range from $1.50 to $4.00 each, price depends on size of cookie and design.</p><p>Cookie favors wrapped in individual cellophane bags tied with ribbon, will have an added charge of $.25 to each favor. (Depending on quantity discount would be provided.)</p><h2>Cookie Girl Party Platters:</h2><p>Party platters are a great addition to your dessert table. The display of assorted cookie sizes and designs created in the theme of your event is a detail that will not be missed. Just provide your party theme and together we can design a custom Party Platter specifically for your affair.</p><p>Please understand that the cookie sizes will vary, starting from 4 inch cookies down to mini cookies which are 1-2 inches.</p><p>You may if you like trade the message cookie for two regular size cookies.</p><h3>Party Platter Sizes:</h3><input type="checkbox" name="small party platter" />Small Party Platter $32.00 - 24 assorted size and design cookies, plus 1 message cookie<br/ ><br/ ><input type="checkbox" name="medium party platter" />Medium Party Platter $52.00 - 42 assorted size and design cookies, plus 1 message cookie<br/ ><br/ ><input type="checkbox" name="large party platter" />Large Party Platter $72.00 - 60 assorted size and design cookies, plus 1 message cookie<br/ ><h2>Cookie Girl Cookie Bouquets</h2><p>Cookie Bouquets are an edible floral expression! They can be designed to fit any occasion: Easter, Mother's Day, New Baby, New Home, Thank You and everything in between.</p><p>Please note that I am open to all ideas and together we can create the perfect bouquet.</p><input type="checkbox" name="small bouquet" />Small Bouquet $19.99 - six 4-6 inch cookies and two 2 inch cookies, beautifully arranged and wrapped with a bow and note card<br/ ><br/ ><input type="checkbox" name="medium bouquet" />Medium Bouquet $29.99 - ten 4-6 inch cookies, beautifully arranged and wrapped with a bow and note card<br/ ><br/ ><input type="checkbox" name="large bouquet" />Large Bouquet $49.99 - fifteen 4-6 inch cookies, beautifully arranged and wrapped with a bow and note card<br/ ><h2>Cookie Girl Personalized Gift Boxes</h2><p>Cookie Gift Boxes are a great idea for special occasions or just because. These boxes contain six to eight personalized cookies in the theme of your choice and deliver a special message to your special someone. Prices start at $29.99</p><h2>Cookie Girl Cookie Minis</h2><p>Cookie Minis are delicious bites of our cookies. 12 Bites come in a bag. These cookies can be used throughout the Cookie Girl product line.</p><input type="checkbox" name="minis" /><select name="quantity minis"> <option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option></select>1 Dozen Cookie Minis $6.00<br/ ><br/ ><input type="checkbox" name="personalization" />Personalization $1.00 (Per Dozen)<br/ ><hr/ ><h1>Information</h1>Full Name: <input type="text" name="full name" size="30" /><br/ ><br/ >Address: <input type="text" name="address" size="40" /><br/ ><br/ >City: <input type="text" name="city" size="20" />State: <select name="state">	<option value="AL">Alabama</option>	<option value="AK">Alaska</option>	<option value="AZ">Arizona</option>	<option value="AR">Arkansas</option>	<option value="CA">California</option>	<option value="CO">Colorado</option>	<option value="CT">Connecticut</option>	<option value="DE">Delaware</option>	<option value="DC">District of Columbia</option>	<option value="FL">Florida</option>	<option value="GA">Georgia</option>	<option value="HI">Hawaii</option>	<option value="ID">Idaho</option>	<option value="IL">Illinois</option>	<option value="IN">Indiana</option>	<option value="IA">Iowa</option>	<option value="KS">Kansas</option>	<option value="KY">Kentucky</option>	<option value="LA">Louisiana</option>	<option value="ME">Maine</option>	<option value="MD">Maryland</option>	<option value="MA">Massachusetts</option>	<option value="MI">Michigan</option>	<option value="MN">Minnesota</option>	<option value="MS">Mississippi</option>	<option value="MO">Missouri</option>	<option value="MT">Montana</option>	<option value="NE">Nebraska</option>	<option value="NV">Nevada</option>	<option value="NH">New Hampshire</option>	<option value="NJ" selected="yes">New Jersey</option>	<option value="NM">New Mexico</option>	<option value="NY">New York</option>	<option value="NC">North Carolina</option>	<option value="ND">North Dakota</option>	<option value="OH">Ohio</option>	<option value="OK">Oklahoma</option>	<option value="OR">Oregon</option>	<option value="PA">Pennsylvania</option>	<option value="RI">Rhode Island</option>	<option value="SC">South Carolina</option>	<option value="SD">South Dakota</option>	<option value="TN">Tennessee</option>	<option value="TX">Texas</option>	<option value="UT">Utah</option>	<option value="VT">Vermont</option>	<option value="VA">Virginia</option>	<option value="WA">Washington</option>	<option value="WV">West Virginia</option>	<option value="WI">Wisconsin</option>	<option value="WY">Wyoming</option></select><br/ ><br/ >Phone: <input type="text" name="phone" size="20"/><br/ ><br/ >Event: <input type="text" name="event"/><br/ ><br/ ><label for="message">Message/Special Instructions:</label> <textarea name="message" rows=8 cols=50></textarea><br/ ><button type="submit">Submit Order</button></form>

Thank you so much for your help!~Jess :)

Link to comment
Share on other sites

Since your form is submitted through post, you need to use the $_POST array in PHP to get the data from it. So whatever they filled out in the "event" field would be in $_POST['event']. It looks like you're trying to use the user's email address in the form, but I don't see an email field there.The w3schools site has a couple tutorials for handling forms with PHP, and there's also a description here:http://w3schools.invisionzone.com/index.php?showtopic=12509

Link to comment
Share on other sites

Since your form is submitted through post, you need to use the $_POST array in PHP to get the data from it. So whatever they filled out in the "event" field would be in $_POST['event']. It looks like you're trying to use the user's email address in the form, but I don't see an email field there.The w3schools site has a couple tutorials for handling forms with PHP, and there's also a description here:http://w3schools.invisionzone.com/index.php?showtopic=12509
I have tried using the tutorials you've both given me and when I add the $post to try and get the form data, when i hit submit it just shows me the php code in my browser.Do you know what i'm going wrong?
Link to comment
Share on other sites

Okay, so I was being stupid. The form itself is working, but for some reason I am only getting emailed the section of data from the message box and not any of the other info entered in the form, the size of cookie platter, etc.

<?php$smallpartyplatter = $_POST['small party platter'];$mediumpartyplatter = $_POST['medium party platter'];$largepartyplatter = $_POST['large party platter'];$smallbouquet = $_POST['small bouquet'];$mediumbouquet = $_POST['medium bouquet'];$largebouquet = $_POST['large bouquet'];$name = $_POST['full name'];$email = $_POST['email'];$address = $_POST['address'];$city = $_POST['city'];$state = $_POST['state'];$phone = $_POST['phone'];$event = $_POST['event'];$message = $_POST['message'];mail( "j.mandm.design@gmail.com", "Online Cookie Order",    $message, "From: $email" );/* Prepare autoresponder subject */$respond_subject = "Jersey Cookie Girl: Thank you for your order!";/* Prepare autoresponder message */$respond_message = "Thank you for your order!We look forward to discussing the details of your special event with you to ensure a unique design is achieved and your occasion is memorable. Cookie Girl takes great pride in creating beautiful and edible designs and will be in touch with you in the next 48hrs. Thank you,Nicole BorotaCookie Girlwww.jerseycookiegirl.com";/* Send the message using mail() function */mail($email, $respond_subject, $respond_message);header( "Location: [url="http://www.jerseycookiegirl.com/thankyou.shtml""]http://www.jerseycookiegirl.com/thankyou.shtml"[/url] );?>

          <h1>cookie order form</h1><form name="order form" action="process.php" method="post"><p>Jersey Cookie Girl offers Cookie Favors, Cookie Party Platters, Cookie Bouquets and Cookie Gift Boxes.</p><h2>Cookie Girl Cookie Favors:</h2> <p>Custom cookie prices range from $1.50 to $4.00 each, price depends on size of cookie and design.</p><p>Cookie favors wrapped in individual cellophane bags tied with ribbon, will have an added charge of $.25 to each favor. (Depending on quantity discount would be provided.)</p><h2>Cookie Girl Party Platters:</h2><p>Party platters are a great addition to your dessert table. The display of assorted cookie sizes and designs created in the theme of your event is a detail that will not be missed. Just provide your party theme and together we can design a custom Party Platter specifically for your affair.</p><p>Please understand that the cookie sizes will vary, starting from 4 inch cookies down to mini cookies which are 1-2 inches.</p><p>You may if you like trade the message cookie for two regular size cookies.</p><h3>Party Platter Sizes:</h3><input type="checkbox" name="small party platter" value="small party platter" />Small Party Platter $32.00 - 24 assorted size and design cookies, plus 1 message cookie<br/ ><br/ ><input type="checkbox" name="medium party platter" value="medium party platter" />Medium Party Platter $52.00 - 42 assorted size and design cookies, plus 1 message cookie<br/ ><br/ ><input type="checkbox" name="large party platter" value="large party platter" />Large Party Platter $72.00 - 60 assorted size and design cookies, plus 1 message cookie<br/ ><h2>Cookie Girl Cookie Bouquets</h2><p>Cookie Bouquets are an edible floral expression! They can be designed to fit any occasion: Easter, Mother's Day, New Baby, New Home, Thank You and everything in between.</p><p>Please note that I am open to all ideas and together we can create the perfect bouquet.</p><input type="checkbox" name="small bouquet" value="small bouquet" />Small Bouquet $19.99 - six 4-6 inch cookies and two 2 inch cookies, beautifully arranged and wrapped with a bow and note card<br/ ><br/ ><input type="checkbox" name="medium bouquet" value="medium bouquet" />Medium Bouquet $29.99 - ten 4-6 inch cookies, beautifully arranged and wrapped with a bow and note card<br/ ><br/ ><input type="checkbox" name="large bouquet" value="large bouquet" />Large Bouquet $49.99 - fifteen 4-6 inch cookies, beautifully arranged and wrapped with a bow and note card<br/ ><h2>Cookie Girl Personalized Gift Boxes</h2><p>Cookie Gift Boxes are a great idea for special occasions or just because. These boxes contain six to eight personalized cookies in the theme of your choice and deliver a special message to your special someone. Prices start at $29.99</p><h2>Cookie Girl Cookie Minis</h2><p>Cookie Minis are delicious bites of our cookies. 12 Bites come in a bag. These cookies can be used throughout the Cookie Girl product line.</p><input type="checkbox" name="minis" /><select name="quantity minis"> <option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option></select>1 Dozen Cookie Minis $6.00<br/ ><br/ ><input type="checkbox" name="personalization" />Personalization $1.00 (Per Dozen)<br/ ><hr/ ><h1>Information</h1>Full Name: <input type="text" name="full name" size="30" /><br/ ><br/ >Email: <input type="text" name="email" size="40" /> <br/ ><br/ >Address: <input type="text" name="address" size="40" /><br/ ><br/ >City: <input type="text" name="city" size="20" />State: <select name="state">	<option value="AL">Alabama</option>	<option value="AK">Alaska</option>	<option value="AZ">Arizona</option>	<option value="AR">Arkansas</option>	<option value="CA">California</option>	<option value="CO">Colorado</option>	<option value="CT">Connecticut</option>	<option value="DE">Delaware</option>	<option value="DC">District of Columbia</option>	<option value="FL">Florida</option>	<option value="GA">Georgia</option>	<option value="HI">Hawaii</option>	<option value="ID">Idaho</option>	<option value="IL">Illinois</option>	<option value="IN">Indiana</option>	<option value="IA">Iowa</option>	<option value="KS">Kansas</option>	<option value="KY">Kentucky</option>	<option value="LA">Louisiana</option>	<option value="ME">Maine</option>	<option value="MD">Maryland</option>	<option value="MA">Massachusetts</option>	<option value="MI">Michigan</option>	<option value="MN">Minnesota</option>	<option value="MS">Mississippi</option>	<option value="MO">Missouri</option>	<option value="MT">Montana</option>	<option value="NE">Nebraska</option>	<option value="NV">Nevada</option>	<option value="NH">New Hampshire</option>	<option value="NJ" selected="yes">New Jersey</option>	<option value="NM">New Mexico</option>	<option value="NY">New York</option>	<option value="NC">North Carolina</option>	<option value="ND">North Dakota</option>	<option value="OH">Ohio</option>	<option value="OK">Oklahoma</option>	<option value="OR">Oregon</option>	<option value="PA">Pennsylvania</option>	<option value="RI">Rhode Island</option>	<option value="SC">South Carolina</option>	<option value="SD">South Dakota</option>	<option value="TN">Tennessee</option>	<option value="TX">Texas</option>	<option value="UT">Utah</option>	<option value="VT">Vermont</option>	<option value="VA">Virginia</option>	<option value="WA">Washington</option>	<option value="WV">West Virginia</option>	<option value="WI">Wisconsin</option>	<option value="WY">Wyoming</option></select><br/ ><br/ >Phone: <input type="text" name="phone" size="20"/><br/ ><br/ ><label for="event">Event:</label> <input type="text" name="event"/><br/ ><br/ ><label for="message">Message/Special Instructions:</label> <textarea name="message" rows=8 cols=50></textarea><br/ ><button type="submit">Submit Order</button></form>

Thanks again for all of you help,~Jess :)

Link to comment
Share on other sites

right, well it's only going to send you what you tell it to send. Your code currently only has $message as being equal $_POST['message']; If you want more info, you are going to have to construct a message using all the other form fields.i.e.

$message = "Name: $name \n Email Address: $email \n Message: $message \n";

Link to comment
Share on other sites

right, well it's only going to send you what you tell it to send. Your code currently only has $message as being equal $_POST['message']; If you want more info, you are going to have to construct a message using all the other form fields.i.e.
$message = "Name: $name \n Email Address: $email \n Message: $message \n";

Ooooh. so basically what you're saying is I have to put all of the other form fields under $message = for the email to contain all of those fields. What does the \n mean?Thanks!~Jess :)
Link to comment
Share on other sites

What does the \n mean?
It is new line feed.in one line it can take 70 characters after that you should use \n to go to next line. for long message it is annonoying to insert \n on currect place everytime. There is a function to do that job little easier wordwrap(). If you are unsure how to use it youmay want to check the page mail() there is a example of usage of it.
Is there a way to show a quick text line if a checkbox is checked?
Do you want it do dynamicaly? I mean when the user check a box? or after form submit?
Link to comment
Share on other sites

It is new line feed.in one line it can take 70 characters after that you should use \n to go to next line. for long message it is annonoying to insert \n on currect place everytime. There is a function to do that job little easier wordwrap(). If you are unsure how to use it youmay want to check the page mail() there is a example of usage of it.Do you want it do dynamicaly? I mean when the user check a box? or after form submit?
Yes, I want it to show only when a checkbox is checked. Immediately. Not after the form is submitted.Thanks~Jess :)
Link to comment
Share on other sites

Yes, I want it to show only when a checkbox is checked. Immediately. Not after the form is submitted.Thanks~Jess :)
you would need to use javascript for that. It would require doing something along the lines that when the checkbox is checked, run a function to see if it is unchecked and if it is, then do something. In this case, it would be outputting some sort of message on the screen to the user.http://www.w3schools.com/jsref/prop_checkbox_checked.asp
It is new line feed.in one line it can take 70 characters after that you should use \n to go to next line. for long message it is annonoying to insert \n on currect place everytime. There is a function to do that job little easier wordwrap(). If you are unsure how to use it youmay want to check the page mail() there is a example of usage of it.
Or, if you intentionally want your form fields to be on their own line, the \n will basically 'list' them out. wordwrap would be good for the message though, where you don't know how long it might be.
Link to comment
Share on other sites

Archived

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

×
×
  • Create New...