Forum Home
Press F1
 
Thread ID: 98635 2009-04-01 03:42:00 Form Sending PHP csinclair83 (200) Press F1
Post ID Timestamp Content User
761459 2009-04-01 03:42:00 Hey Guys - Been a while since i've been here . . . . lots happened! got a baby girl now, beautiful wee one :)

I've dug myself a hole with PHP and cant figure it out :confused: . . . . I've made the HTML form in frontpage - am using Dreamweaver to do the site, but using frontpage for the forms as i cant figure it out in DW . . .
Made an PHP script to go with it so it can be submitted to me in a email .
After days of struggles I've finally got it to send an email to me, with name, address, contents of text boxes . But I'm still having trouble when it " reads " check boxes and drop down lists - I've got 5 check boxes, if i tick the 1st one or the 4th one it reads by PHP, but the other 3 wont . . . . even though they're written the same as the 2 that work . . .
Drop down boxes wont be read at all . . .

I'm also having trouble getting the PHP to read upload functions - have read some tutorials and tried adding codes but none i tried worked . . .

Would be aweosme if someone could help me get this up and running . . . . its driving me crazy!! :waughh:

heres the PHP code . . . and the HTML code can be found at www . oceansidegraphics . co . nz/OrderFormCoffeeMug . html

<?php
// Step 1
$subject = " Order Form " ;
$name = $_POST['Name'];
$email = $_POST['Email'];
$address = $_POST['Address'];
$phone = $_POST['Phone'];
$coffee = $_POST['WhiteMug'];
$coffee = $_POST['BlackInside'];
$coffee = $_POST['BlueInside'];
$coffee = $_POST['MaroonInside'];
$coffee = $_POST['YellowInside'];
$coffee = $_POST['GreenInside'];
$mugtxt = $_POST['TextonMug'];
$colortxt = $_POST['Colour'];
$colortxt = $_POST['OtherColour'];
$othertxt = $_POST['ExtraText'];
$extrainfo = $_POST['ExtraInfo'];

$to = " user@example . com " ; // The e-mail address you want the message sent to

// Step 2
$header = " From: " . $name . " < " . $email . " > " ;
$message = " Name: $name \r
Address: $address \r
Phone: $phone \r
EMAIL: $email \r
Coffee Mug: $coffee \r
Coffee Mug Text: $mugtxt \r
Color Text: $colortxt \r
Additional Text: $othertxt \r
Additional Info: $extrainfo \r " ;

// Step 3
mail($to, $subject, $message, $header);

// Step 4
header( " Location: . oceansidegraphics . co . nz/thankyou . htm " " target="_blank">www . oceansidegraphics . co . nz);
?><head><title>Script to Send Form to Email</title></head>
csinclair83 (200)
761460 2009-04-01 03:54:00 1. You're using the wrong control for selecting the mug interior colour - you should be using a radio group, not checkboxes. There's nothing obvious that would prevent the other checkboxes from being read, but note that as things are currently you'll only get the value for the last checkbox on the page that's checked (because you are overwriting $coffee every time). I suggest you switch to using a radio group control, then let us know if you're still having trouble with it.

2. For uploading files, you need to set the form type to multipart/form-data - you've missed this bit.
Erayd (23)
761461 2009-04-01 03:59:00 similarly the "Colour" select box and "Other colour" input box are overwriting each other.

Use another variable:


$colortxt = $_POST['Colour'];
$otherColorTxt = $_POST['OtherColour'];
dyewitness (9398)
761462 2009-04-01 05:27:00 wow cant beleive i missed how those 2 are identical - will fix :) csinclair83 (200)
761463 2009-04-01 05:27:00 I'll change them to Radio buttons and also the multidata - where do I add that bit? csinclair83 (200)
761464 2009-04-01 05:38:00 <form enctype="multipart/form-data">Obviously that's an abbreviated version - you still need your method, action etc attributes! Erayd (23)
761465 2009-04-01 06:05:00 ooook....now I'm confused, and maybe this is the best time to say I'm a complete newbie! I sourced the script called simplescript.php but readed a few tutorials and managed to make changes and just got it working by trial and error but 3 days on these 2 mistakes - upload file and the checkboxes...got me nowhere so am here..

Could someone explain more or lead me to some better more indepth tutorials that start at the start?
csinclair83 (200)
761466 2009-04-01 06:21:00 The "multipart/form-data" just tells the browser to format the data in it's POST in a special format (files/regular form variables etc).

Have a look at this tutorial:
www.w3schools.com
dyewitness (9398)
761467 2009-04-01 06:23:00 $to = "user@example.com"; // The e-mail address you want the message sent to


Hope that's not a real address you've provided in the code?

Spambots will love that!
nofam (9009)
761468 2009-04-01 06:46:00 how can i edit to remove addy? csinclair83 (200)
1 2 3 4