Контактная форма PHP

incognito2007
На сайте с 13.02.2007
Offline
30
1307

Я PHP не знаю, поэтому прошу помощи у вас.

Сама, как умела, сделала сборную форму, добавив нужные мне параметры из нескольких скриптов.

Одна проблема - тема письма не высвечивается. Сообщение приходит в виде "Без темы".

Вот форма

<form method="post" action="send_contact.php">
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr>
<td width="16%">Subject</td>
<td width="2%">:</td>
<td width="82%"><select name="attn" size="1">
<option value="Тема">Тема</option>
</select>

</td>
</tr>
<tr>
<td>Detail</td>
<td>:</td>
<td><textarea name="detail" cols="50" rows="4" id="detail"></textarea></td>
</tr>
<tr>
<td>Name</td>
<td>:</td>
<td><input name="name" type="text" id="name" size="50"></td>
</tr>
<tr>
<td>Email</td>
<td>:</td>
<td><input name="customer_mail" type="text" id="customer_mail" size="50"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td>
</tr>
</table>
</form>

Вот файл send_contact.php

<?php
$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];
$str=@iconv("koi8-r","windows-1251",@iconv("UTF-8","koi8-r",$str));



$todayis = date("l, F j, Y, g:i a") ;




$notes = stripcslashes($notes);


// Contact subject
$attn = "$attn";

// Details
$message="$detail
$todayis [EST] \n
Attention: $attn \n
Message: $notes \n
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

// Mail of sender
$mail_from="$customer_mail";
// From
$header="Content-type: text/html; charset=windows-1251\r\nfrom: $name <$mail_from>";

// Enter your email address
$to ='х@gmail.com';

$send_contact=mail($to,$subject,$message,$header);

// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
echo "We've recived your contact information";
}
else {
echo "ERROR";
}
?>

<p align="center">
Дата: <?php echo $todayis ?>
<br />
Спасибо : <?php echo $visitor ?> ( <?php echo $visitormail ?> )
<br />

Attention: <?php echo $attn ?>
<br />
Сообщение<br />
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo $ip ?>

<br /><br />
<a href="ххх.html"> <strong>Вернуться</strong> </a>
</p>

Буду безмерна благодарна за подсказку :)

Забыла добавить:

При правке $send_contact=mail($to,$subject,$message,$header);

на $send_contact=mail($to,$attn,$message,$header);

выходит ещё хуже - отправитель тоже становится неизвестным, а тема написана в непонятной кодировке

kil
На сайте с 03.04.2006
Offline
84
kil
#1

Типа этого:

<?php

$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];
$str=@iconv("koi8-r","windows-1251",@iconv("UTF-8","koi8-r",$str));



$todayis = date("l, F j, Y, g:i a") ;




$notes = stripcslashes($notes);


// Contact subject
$attn = "$attn";
$subject=$attn;


// Details
$message="$detail
$todayis [EST] \n
Attention: $attn \n
Message: $notes \n
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

// Mail of sender
$mail_from="$customer_mail";
// From
$header="Content-type: text/html; charset=windows-1251\r\nfrom: $name <$mail_from>";

// Enter your email address
$to ='х@gmail.com';

$send_contact=mail($to,$subject,$message,$header);

// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
echo "We've recived your contact information";
}
else {
echo "ERROR";
}
?>

<p align="center">
Дата: <?php echo $todayis ?>
<br />
Спасибо : <?php echo $visitor ?> ( <?php echo $visitormail ?> )
<br />

Attention: <?php echo $attn ?>
<br />
Сообщение<br />
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo $ip ?>

<br /><br />
<a href="ххх.html"> <strong>Вернуться</strong> </a>
</p>

Если я все правильно понял.

incognito2007
На сайте с 13.02.2007
Offline
30
#2

kil, спасибо, но в этом случае получается тема к непонятной кодировке, а отправитель неизвестен :(

kil
На сайте с 03.04.2006
Offline
84
kil
#3

Еще раз:

<?php

$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];
$str=@iconv("koi8-r","windows-1251",@iconv("UTF-8","koi8-r",$str));



$todayis = date("l, F j, Y, g:i a") ;




$notes = stripcslashes($notes);


// Contact subject
$attn = "$attn";

// Details
$message="$detail
$todayis [EST] \n
Attention: $attn \n
Message: $notes \n
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

// Mail of sender
$mail_from="$customer_mail";
// From
$header="Content-type: text/html; charset=windows-1251\r\nfrom: $visitor <$visitormail>";

// Enter your email address
$to ='х@gmail.com';

$send_contact=mail($to,$subject,$message,$header);

// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
echo "We've recived your contact information";
}
else {
echo "ERROR";
}
?>

<p align="center">
Дата: <?php echo $todayis ?>
<br />
Спасибо : <?php echo $visitor ?> ( <?php echo $visitormail ?> )
<br />

Attention: <?php echo $attn ?>
<br />
Сообщение<br />
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo $ip ?>

<br /><br />
<a href="ххх.html"> <strong>Вернуться</strong> </a>
</p>
incognito2007
На сайте с 13.02.2007
Offline
30
#4

Огромное спасибо ещё раз.

Теперь имеем следующую картину - тема "без темы" (вместо каракуль прошлой версии)

Отправитель - "неизвестный отправитель" 😕

А может есть возможность где-то указать кодировку для названия темы? 😕

kil
На сайте с 03.04.2006
Offline
84
kil
#5

Блин! Сколько же лишнего там понаписано!

<?php

$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];
$str=@iconv("koi8-r","windows-1251",@iconv("UTF-8","koi8-r",$str));

$name=$_POST['name'];
$customer_mail=$_POST['customer_mail'];


$todayis = date("l, F j, Y, g:i a") ;




$notes = stripcslashes($notes);


// Contact subject
$attn = "$attn";

// Details
$message="$detail
$todayis [EST] \n
Attention: $attn \n
Message: $notes \n
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

// Mail of sender
$mail_from="$customer_mail";
// From
$header="Content-type: text/html; charset=windows-1251\r\nfrom: $name <$customer_mail>";

// Enter your email address
$to ='х@gmail.com';

$send_contact=mail($to,$subject,$message,$header);

// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
echo "We've recived your contact information";
}
else {
echo "ERROR";
}
?>

<p align="center">
Дата: <?php echo $todayis ?>
<br />
Спасибо : <?php echo $visitor ?> ( <?php echo $visitormail ?> )
<br />

Attention: <?php echo $attn ?>
<br />
Сообщение<br />
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo $ip ?>

<br /><br />
<a href="ххх.html"> <strong>Вернуться</strong> </a>
</p>
incognito2007
На сайте с 13.02.2007
Offline
30
#6

kil, спасибо Вам, добрый человек :)

Но мне уже неудобно отнимать у Вас время.

Имя отправителя есть, тема - "без темы" .......

Во всем запросе мне важно знать ip отправителя, тему (этот параметр я указываю сама для каждой страницы), адрес отправителя и само сообщение.

kil
На сайте с 03.04.2006
Offline
84
kil
#7

Пропустил

<?php

$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];
$str=@iconv("koi8-r","windows-1251",@iconv("UTF-8","koi8-r",$str));

$name=$_POST['name'];
$customer_mail=$_POST['customer_mail'];


$todayis = date("l, F j, Y, g:i a") ;




$notes = stripcslashes($notes);


// Contact subject
$attn = "$attn";
$subject=$attn;

// Details
$message="$detail
$todayis [EST] \n
Attention: $attn \n
Message: $notes \n
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

// Mail of sender
$mail_from="$customer_mail";
// From
$header="Content-type: text/html; charset=windows-1251\r\nfrom: $name <$customer_mail>";

// Enter your email address
$to ='х@gmail.com';

$send_contact=mail($to,$subject,$message,$header);

// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
echo "We've recived your contact information";
}
else {
echo "ERROR";
}
?>

<p align="center">
Дата: <?php echo $todayis ?>
<br />
Спасибо : <?php echo $visitor ?> ( <?php echo $visitormail ?> )
<br />

Attention: <?php echo $attn ?>
<br />
Сообщение<br />
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo $ip ?>

<br /><br />
<a href="ххх.html"> <strong>Вернуться</strong> </a>
</p>

kil добавил 04.02.2009 в 23:50

В общем, если работать не будет, напишите мне ЛС.

Будет свободное время - помогу )

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий