Thread: Form - checkboxes & file upload
Results 1 to 2 of 2
09-11-2009, 03:42 AM #1
Form - checkboxes & file upload
I have currently finished producing a form using php to abstract the data entered; as well as sending it to a particular address.
1.Trouble displaying more than 1 checkbox's value. I'v got 4 checkboxes relating to different times suitable in the day. Unfortunately atm it'll only display the value of the last checkbox ticked and not the rest.
2.My form also requires uploading a file and was wondering how do we manage it?
PHP CODE IS AS FOLLOWS
mail("email address","Subject","Form data:
First Name: " . $_POST['first_name'] . "
Last Name: " . $_POST['last_name'] . "
Email: " . $_POST['email'] . "
Street: " . $_POST['street'] . "
Suburb: " . $_POST['suburb'] . "
Post Code: " . $_POST['post_code'] . "
Ethnicity: " . $_POST['ethnicity'] . "
Date of Birth - Month: " . $_POST['dobm'] . "
Date of Birth - Day: " . $_POST['dobd'] . "
Date of Birth - Year: " . $_POST['doby'] . "
Phone: " . $_POST['contact_number1'] . "
Mobile: " . $_POST['contact_number2'] . "
Suitable Contact Times: " . $_POST['time'] . "
Are You Overseas?: " . $_POST['overseas'] . "
Date of Return - Month: " . $_POST['backm'] . "
Date of Return - Day: " . $_POST['backd'] . "
Date of Return - Year: " . $_POST['backy'] . "
How Did You Hear About Us: " . $_POST['hear'] . "
Enquiry: " . $_POST['enquiry'] . "
Last edited by Bigmous; 09-11-2009 at 10:30 AM.
09-17-2009, 10:02 AM #2
Re: Form - checkboxes & file upload
In the form declaration, add:
<input type="hidden" name="MAX_FILE_SIZE" value="2097152" />
A couple things to remember when allowing files to be uploaded via a form:
- PHP has a set limit on the maximum file size allowed in the upload. The default is set to 3MB, but can be changed in the php.ini. If you are on a shared server, your hosting provider will most likely have to change it, but will more than likely not be willing to.
- The file is uploaded to a temporary location. If you do nothing with the $_FILES superglobal array, you will lose the file.
- Make sure you include error handling in your PHP code to verify the file has been uploaded. There is an error code that comes through that will tell you what the problem was.