|
|
|
| Перед текстом письма появляются переводы строк, как от них можно избавится. На вякий случай дам сам код.
<?php
if(!empty($_POST)and(($_POST['name']!='')and($_POST['mail']!='')and($_POST['text']!=''))and(preg_match("|^[-0-9a-z_]+@+[-0-9a-z^\.]+\.[a-z]{2,6}$|i", $_POST['mail'])))
{
if(!get_magic_quotes_gpc())
{
$_POST['name'] = mysql_escape_string($_POST['name']);
$_POST['mail'] = mysql_escape_string($_POST['mail']);
$_POST['phone'] = mysql_escape_string($_POST['phone']);
$_POST['text'] = mysql_escape_string($_POST['text']);
}
mysql_query("Insert into ".$this->prefix."feedback values (NULL, '".$_POST['name']."', '".$_POST['mail']."', '".$_POST['phone']."', '".$_POST['text']."', NOW(), '')");
$to = "dimka23_89@mail.ru";
// $to = "mail@aluterrask.ru";
$subject = "Новый вопрос";
$headers = "Content-Type: text/html; charset=windows-1251\r\n";
$headers .= "From: <".$_POST['mail'].">";
$msg = "
<html>
<head></head>
<body>
<table >
<tr>
<td>Имя:</td>
<td>".$_POST['name']."</td>
</tr>
<tr>
<td>Почта:</td>
<td>".$_POST['mail']."</td>
</tr>
<tr>
<td>Телефон:</td>
<td>".$_POST['phone']."</td>
</tr>
<tr>
<td>Текст вопроса:</td>
<td>".$_POST['text']."</td>
</tr>
</table>
</body>
</html>";
if(mail($to, $subject, $msg, $headers))
{
$this->text .= "<p>Ваш вопрос принят. <a href='http://".$_SERVER['HTTP_HOST']."/".$_GET['type']."'>Задать вопрос</a></p>";
}
}
else
{
$this->text .= "<form method=post><h1>Задать вопрос</h1><table width=600 height=1 border=0 cellpadding=0 cellspacing=0><td width=100% bgcolor=#dbdbdb></td></table><br>";
if((!empty($_POST))and(($_POST['name']=='')or($_POST['mail']=='')or($_POST['text']=='')))
{
$this->text .= "<p><font color='red'> * - обязательные поля не заполнены!</font></p>";
}
if((!empty($_POST))and(!preg_match("|^[-0-9a-z_]+@+[-0-9a-z^\.]+\.[a-z]{2,6}$|i", $_POST['mail'])))
{
$this->text .= " <p> <font color='red'> Неверен формат E-mail. Введите E-mail формата somebody@some.ru</font></p>";
}
$this->text .= "
<table width=600 cellpadding=0 cellspacing=0>
<tr>
<td width=130><p>Имя: <font color='red'>*</font></p></td><td width=520><p><input name='name' style='width:520' value='".$_POST['name']."'></p></td>
</tr>
<tr>
<td><p>E-mail: <font color='red'>*</font></p></td><td><p><input name='mail' style='width:100%' value='".$_POST['mail']."'></p></td>
</tr>
<tr>
<td><p>Телефон:</p></td><td><p><input name='phone' style='width:100%' value='".$_POST['phone']."'></p></td>
</tr>
<tr>
<td valign=top><p>Текст вопроса: <font color='red'>*</font></p></td><td><p><textarea name='text' rows=6 style='width:520'>".$_POST['text']."</textarea></p></td>
</tr>
</table>
<p><font color='red'> * </font><font color='#003f82'> - помечены обязательные поля для заполнения</font></p>
<input type='submit' value=' Отправить '>
</form>";
}
?>
|
| |
|
|
|
|
|
|
|
для: Dimka31
(17.07.2008 в 12:18)
| | 1. Сделайте trim() всех принятых перменных
2.
<?
$headers .= "From: <".$_POST['mail'].">\r\n";
?>
|
| |
|
|
|