PHP电子邮件表单不发送所有字段

时间:2010-11-16 22:03:10

标签: php html email forms field

这是我的html表格

<form  action="formmail1.php" method="post" enctype="multipart/form-data">

<li>
Name<br /><input name="name" type="text" id="name" size="50" maxlength="50" /> <br />
First and Last Name<br /><br />
</li>

<li>
Phone<br /><input name="phone" Type="text" id="email" size="12" maxlength="12"/><br />
___-___-____<br /><br />
</li>

<li>
Email<br />
<input name="email" Type="text" id="email" size="50"/><br />
Valid email address<br /><br />
</li>

<li>
How do you want to be contacted?<br />
<input Type="radio" name="how_to_be_contacted" id="r1" class="radio" value="1" /><label for="r1">Email</label><br />
<input Type="radio" name="how_to_be_contacted" id="r2" class="radio" value="2" /><label for="r1">Phone</label><br /><br />
</li>

<li>
I would like information about...<br />
<input name="aquatic_therapy" type="checkbox" id="aquatic_therapy" />Aquatic Therapy&nbsp;&nbsp;&nbsp;&nbsp;<input name="occupational_therapy" type="checkbox" id="occupational_therapy" />Occupational Therapy<br />
<input name="speech_therapy" type="checkbox" id="speech_therapy" />Speech Therapy&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="reflex_integration" type="checkbox" id="reflex_integration" />Reflex Integration
<br />
Select all that apply<br />
</li>
<br />
<li>
Message<br />
<textarea name="message" cols="50" rows="10" id="message"></textarea><br />
</li>

</ol>

<input id="submit" type="submit">

这是我的PHP

<?php

if (isset($_REQUEST['email']))
//if "email" is filled out, send email

  //send email
    $name = $_REQUEST['name'] ;
    $phone = $_REQUEST['phone'] ;
    $email = $_REQUEST['email'] ;
    $how_do_you_want_to_be_contcted = $_REQUEST['how_do_you_want_to_be_contcted'] ;
    $information = $_REQUEST['information'] ;
    $message = $_REQUEST['message'] ;
    mail("email@nowhere.com", "Subject: Contact Us Form",
    $message "From: $email" );
    echo "Thank you for using our mail form";


else
  //if "email" is not filled out, display the form
  echo "<form method='post' action='mailform.php'>
  Email: <input name='email' type='text' /><br />
  Subject: <input name='subject' type='text' /><br />
  Message:<br />
  <textarea name='message' rows='15' cols='40'>
  </textarea><br />
  <input type='submit' />
  </form>";

发送的只是消息文本字段,但没有其他字段....

3 个答案:

答案 0 :(得分:2)

$_REQUEST['how_do_you_want_to_be_contcted']无效,因为HTML代码中的字段名称为how_to_be_contacted

您将手机字段定义为$phone,然后引用$emailphone。这显然也无济于事。

mail("eweb@gmail.com", "Subject: Contact Us Form", $emailphone
$message "From: $email" );

这有语法错误,因此根本无法正常工作。

您尚未转义任何输入值,因此如果有人输入了包含无效数据的内容,则可能会破坏该程序和/或导致该网站遭到入侵。

答案 1 :(得分:1)

除非选中,否则不会发送复选框和单选按钮。

答案 2 :(得分:0)

这是另一种可能性:

您要求的请求名称是:how_do_you_want_to_be_contcted 在你的表格中你称之为:how_to_be_contacted