doutuo7815 2013-01-01 15:04
浏览 11
已采纳

PHP $ _POST为空[重复]

Possible Duplicate:
method=“post” enctype=“text/plain” are not compatible?

I know this topic was few times on this forum, but none of this solved my problem.

When i try send "contact" data from html site, using method POST, on my php site im getting empty $_POST. I checked one hundert sites and tutorials. I did exacly same like it was showed... Using method "GET" im getting data, but i cant go this way. URL too long.

this is my HTML code.

<form  name="post" id="post" method="POST" action="http://podsmoczymdiamentem.host56.com/post.php"  enctype="text/plain">
<table BORDER="0" CELLSPACING="0" CELLPADDING="4">
<tr><td colspan="2"><b>Tytuł:</B></TD></tr>
<tr><td colspan="2"><input type="text" name="tytul" id="tytul" size="30"></TD></TR>
<tr><td colspan="2"><b>Treść:</B></TD>
<tr> <td colspan="2"><textarea name="opowiadanie" cols="70" wrap="virtual" rows="30"></TEXTAREA></TD></TR>
<tr><td align="right"></TD><td align="right"><b>Imię:</B><input type="text" name="autor" size="20"></TD></TR>
<tr><td></TD><td align="right"><b>e-mail:</B><input type="text" name="e-mail" size="20"></TD></TR>
<tr> <td>&nbsp;</TD> <td align="right">
<input type="submit" name="submit" value="Wyślij"><input type="reset" name="reset" value="Wyczyść">
</TD></TR>
</TABLE></FORM></div> 

and PHP

<?php
      if (empty($_POST['submit'])) {
        echo 'Wiadomość jest pusta!';
     }else{    
      $autor = $_POST['autor'];
      $tytul = $_POST['tytul'];
      $subject = "$autor nadesłał swoją opowieść: $tytul";
      $nadawca = $_POST['e-mail'];
      $adresat = 'podsmoczymdiamentem@gmail.com'; 
      $opowiadanie = $_POST['opowiadanie'];
      $headers .= "Content-Type: text/html; charset=ISO-8859-2
";
      $subject = "=?ISO-8859-2?B?".base64_encode($subject)."?=";
      $tresc = "Witaj Marcinie. Użytkownik <b>$autor</b> nadesłał opowiadanie do twej karczmy. Oto ono:<br><br><b><h1>$tytul</h1></b><br><br> $opowiadanie";
      $mail_sent = @mail( $adresat, $subject, $tresc, $headers);
      if($mail_sent == TRUE)
        echo 'Wiadomość została wysłana.';
      else
        echo 'Ups. Coś nie wyszło. Skontaktuj się z karczmarzem PSD w celu wyjaśnienia problemu.';
      }
?>

what im doing wrong?

  • 写回答

1条回答 默认 最新

  • duanchen1937 2013-01-01 15:08
    关注

    You are using the wrong encoding type. Use application/x-www-form-urlencoded instead of text/plain.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路