开发者

forms - processing textarea and checkbox variables

Alright, so I got my form to email most of the variables in php. However, my textarea variables show up blank and my textarea inputs print as "Array"

Here is a snippet from my form:

<label for="ProgramAudience">Intended Audience:</label>
                <span><input type="checkbox" name="ProgramAudience[]" value="AcademicAffairsFaculty" />Academic Affairs/Faculty</span>
                <span><input type="checkbox" name="ProgramAudience[]" value="StudentAffairsDevelopment" />Student Affairs/Development</span>
                <span><input type="checkbox" name="ProgramAudience[]" value="CommunityColl开发者_运维问答ege" />Community College/2-Year Institutions</span>
                <span><input type="checkbox" name="ProgramAudience[]" value="GraduateStudents" />Graduate Students</span>
                <span><input type="checkbox" name="ProgramAudience[]" value="FourYearPublic" />Four-Year Public Institutions</span>
                <span><input type="checkbox" name="ProgramAudience[]" value="FourYearPrivate" />Four-Year Private Institutions</span>



<label for="ExpectedOutcome">Expected Learning Outcomes:</label>
                <label class="small">List 1-2 expected learning outcomes below. (As a result of attending this session, participants will...)</font></label>
                    <font size="1" face="arial, helvetica, sans-serif"> ( You may enter up to 400 characters. )<br>
                <textarea name="message4" id="ExpectedOutcome" class="required" wrap="physical" rows="10" cols="35" onKeyDown="textCounter(this.form.message4,this.form.remLen,400);" onKeyUp="textCounter(this.form.message4,this.form.remLen,400);"></textarea>

Here is the part of the processing file:

$ProgramAudience = $_POST['ProgramAudience']; 
$ExpectedOutcome = $_POST['ExpectedOutcome']; 

...

$Body = "";
$Body .= "ProgramAudience: ";
$Body .= $ProgramAudience;
$Body .= "\n";
$Body .= "ExpectedOutcome ";
$Body .= $ExpectedOutcome;

This is what the emailed result looks like:

From:

To: me@me.net

Date: Thu, 15 Jul 2010 17:10:17 -0400

Subject: Proposal Submission

First Name: miles

Last Name: me

Title: test

Institution: test

EmailFrom: me@me.net

Phone: 8157531503

Address: HSC 023A

City: DeKalb

State: IL

Zip: 60115

CoPresenter: adam

ProgramTitle:

ProgramType: Array

ProgramDescription:

ProgramOutline:

ProgramTopic: Array

ProgramAudience: Array

ExpectedOutcome

Experience:

AVEquipment:


Check your name attribute on the text area - that's the one PHP will use.

Checkboxes will only come through if they are checked, so make sure you check something. With a name with brackets, like "ProgramAudience[]", the $_POST['ProgramAudience'] variable will either be null or an array. You'll want to check if it's an array, and if so, loop through the contents to generate your email.


For the checkbox arrays, the processing script needed this:

$ProgramTitle = $_POST['ProgramTitle']; 
foreach($_POST['ProgramType']  as  $value)  {
$check_msg .= "Checked: $value\n";
} 

and this:

$Body .= "ProgramTitle: ";
$Body .= $ProgramTitle;
$Body .= "\n";
$Body .= "ProgramType: ";
$Body .= $check_msg;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜