【发布时间】:2015-02-23 05:41:35
【问题描述】:
我使用 java 脚本在表单中创建了一个动态下拉列表添加行。以我的形式,我没有从中获得价值。如果我们填写 3 行,只得到一个行值来发送邮件。
我已经更改了现在获取值但无法提交到电子邮件的代码 给我解决方案我该怎么做
<?php
echo $_POST['optionval'][0];
echo $_POST['optionoth'][0];
echo $_POST['date'][0];
echo $_POST['Num'][0];
echo $_POST['num'][0];
echo $_POST['optionval'][2];
echo $_POST['optionoth'][3];
echo $_POST['date'][4];
echo $_POST['Num'][5];
echo $_POST['num'][6];
echo $_POST['optionval'][2];
echo $_POST['optionoth'][2];
echo $_POST['date'][2];
echo $_POST['Num'][2];
echo $_POST['num'][2];
$optionval= $_POST['optionval']; // required
$optionoth= $_POST['optionoth']; // required
$date= $_POST['date']; // required
$Num= $_POST['Num']; // required
$num= $_POST['num']; // required
$email_from = '******@gmail.com';//<== update the email address
$email_subject = "New Order submission";
$message = '<html><body>';
$message .= '<img src="*******" alt="New Appointment" />';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($_POST['optionval']) . "</td></tr>";
$message .= "<tr><td><strong>Phone No:</strong> </td><td>" . strip_tags($_POST['optionoth']) . "</td></tr>";
$message .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($_POST['date']) . "</td></tr>";
$message .= "<tr><td><strong>Phone No:</strong> </td><td>" . strip_tags($_POST['Num']) . "</td></tr>";
$message .= "<tr><td><strong>Phone No:</strong> </td><td>" . strip_tags($_POST['num']) . "</td></tr>";
$message .= "</table>";
$message .= "</body></html>";
$to = "******@gmail.com";//<== update the email address
$headers = "From: $email_from \r\n";
//$headers .= "Reply-To: $visitor_email \r\n";
$headers .= "CC: *******@gmail.com \r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
//Send the email!
mail($to,$email_subject,$message,$headers);
//done. redirect to thank-you page.
if(!isset($_POST['submit']))
{
//This page should not be accessed directly. Need to submit the form.
//echo "error; you need to submit the form!";
}
header( 'Location:www.google.com' );
// Function to validate against any email injection attempts
function IsInjected($str)
{
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str))
{
return true;
}
else
{
return false;
}
}
?>
<table border="0" cellpadding="0" cellspacing="0">
<thead>
<tr>
<td>Option</td>
<td>Text</td>
<td>Num</td>
<td>No</td>
</tr>
</thead>
<tbody class="row">
<tr class="row-nt">
<td>
<select name="optionval[]" class="ceventselect" required="">
<option value="option-1" selected="selected">option-1</option>
<option value="option-2">option-2</option>
<option value="option-3">option-3</option>
<option value="option-4">option-4</option>
</select>
<input name="optionoth[]" type="text" class="optionother" style="display: none;margin-top:10px;">
</td>
<td><input name="date[]" type="text" class="date" required=""></td>
<td>
<select name="Num[]" class="form_field_box4 valid" required="">
<option value="Num-1" selected="selected">Num-1</option>
<option value="Num-2">Num-2</option>
<option value="Num-3">Num-3</option>
<option value="Num-4">Num-4</option>
</select>
</td>
<td>
<input name="num[]" type="number" class="boxnum" required="">
</td>
</tr>
</tbody>
</table>
<button class="add-new-evt">Add Row</button>
<input type="submit" value="Submit">
</div>
</form>
【问题讨论】:
标签: javascript php html email post