联系表格php - 来自“选择名称”表单的电子邮件消息

问题描述:

Everything works I think besides of this part of contact form where user selects his answer from "select name". I suspect that I have to change ".clean_string" in php $email_message for something else but i don't know php at all so I have no idea what should it be.

PHP part:

    $email_message .= "Imię i nazwisko: ".clean_string($_POST["imie"])."
";
$email_message .= "Email: ".clean_string($_POST["email"])."
";
$email_message .= "Telefon: ".clean_string($_POST["telefon"])."
";
$email_message .= "Płatność: ".implode(" ", $_POST['platnosc'])."
";
$email_message .= "Miesiąc: ".clean_string(" ", $_POST['miesiac'])."
";
$email_message .= "Dzień: ".clean_string(" ", $_POST['dzien'])."
";
$email_message .= "Poziom: ".clean_string(" ", $_POST['poziom'])."
";

The 3 last ones are "select name" and I have no respons in email about them.

HTML:

    <div id="formphp" class="java">

<form name="htmlform" method="post" action="email.php">
<table width="561">
<tr>
 <td width="212" align="right" valign="top">
  <label for="imie"> </label>
 </td>
 <td width="337" valign="top">
    <input type="text" input size="12" name="imie" placeholder="Imię i 

Nazwisko">
 </td>
</tr>
<tr>
 <td valign="top" align="right">
  <label for="nazwisko"></label>
 </td>
 <td valign="top">
  <input type="text" input size="12" name="telefon" 

placeholder="Telefon">
 </td>
</tr>
<tr>
 <td valign="top" align="right">
  <label for="email"></label>
 </td>
 <td valign="top">
  <input type="text" input size="15" name="email" placeholder="E-mail">
 </td>
 </tr>

<div id="formmiesiac">

<select name="miesiac">
    <option selected="selected">Grudzień</option>
    <option>Styczeń</option>
        <option>Luty</option>
        <option>Marzec</option>
</select>
</div>

<div id="formdzien">

<select name="dzien"> 
    <option selected="selected">1</option>
    <option>2</option>
        <option>3</option>
        <option>4</option>
        <option>5</option>
        <option>6</option>
        <option>7</option>
        <option>8</option>
        <option>9</option>
        <option>10</option>
        <option>11</option>
        <option>12</option>
        <option>13</option>
        <option>14</option>
        <option>15</option>
        <option>16</option>
        <option>17</option>
        <option>18</option>
        <option>19</option>
        <option>20</option>
        <option>21</option>
        <option>22</option>
        <option>23</option>
        <option>24</option>
        <option>25</option>
        <option>26</option>
        <option>27</option>
        <option>28</option>
        <option>29</option>
        <option>30</option>
        <option>31</option>
</select>
</div>

<div id="formpoziom">

<select name="poziom">
    <option selected="selected">Poziom 1</option>
    <option>Poziom 2</option>
        <option>Poziom 3</option>

</select>
</div>

<div id="formplatnosc">

<input type="checkbox" name="platnosc[]" value="gotowka" 

/>&nbsp;Gotówka<br />

<input type="checkbox" name="platnosc[]" value="voucher" 

/>&nbsp;Voucher<br />

</div>




<tr>
 <td colspan="2" style="text-align:center">
  <center><input type="submit" value="Submit Form"></center>
 </td>
</tr>
</table>
</form>

</div>

In the first four lines, you pass the submitted data as the first parameter to your clean_string() function. In the last three lines you pass two parameters to clean_string() (the space " " as the first parameter and the submitted data as a second parameter). I think this happened because of copying and pasting the implode() line.

Try to pass the form data as the first parameter to clean_string():

$email_message .= "Miesiąc: ".clean_string($_POST['miesiac'])."
";
$email_message .= "Dzień: ".clean_string($_POST['dzien'])."
";
$email_message .= "Poziom: ".clean_string($_POST['poziom'])."
";