douaonong7807 2010-07-15 21:23
浏览 54
已采纳

表单 - 处理textarea和checkbox变量

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="CommunityCollege" />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 .= "
";
$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:

  • 写回答

2条回答 默认 最新

  • doukongpao0903 2010-07-15 21:26
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大