电子邮件送交
晚上好(在这里,在巴西,至少),电子邮件送交
我有一些复选框表格和图像文件输入,但是当我提交它,什么都不会发生。
什么可能是错的?
形式:
<form class="form" enctype="multipart/form-data" method="post" action="envia_email.php">
<fieldset>
<fieldset class="grupo">
<div class="campo">
<label for="nome" id="nome">Nome Completo</label>
<input type="text" id="nome" name="nome" style="width: 10em" value="" />
</div>
</fieldset>
<div class="campo">
<label for="email">E-mail</label>
<input type="text" id="email" name="email" style="width: 13em" value="" />
</div>
<div class="campo">
<label for="email">Local</label>
<input type="text" id="local" name="local" style="width: 13em" value="" />
</div>
<div class="campo">
<label for="telefone">Telefone</label>
<input type="text" id="telefone" name="telefone" style="width: 13em" value="" />
</div>
<input TYPE="checkbox" NAME="whatsapp" VALUE="Whatsapp"> Whatsapp <br><br>
<div class="campo">
<label for="idade">Idade</label>
<input type="text" id="Idade" name="idade" style="width: 3em" value="" />
</div>
<div class="campo">
<label for="cache">Cachê</label>
<input type="text" id="cache" name="cache" style="width: 10em" value="" />
</div>
<div class="campo">
<label for="cache">Atendimento</label>
<input TYPE="checkbox" NAME="atendimento[]" VALUE="Hotéis e Motéis"> Hotéis e Motéis <br><br>
<input TYPE="checkbox" NAME="atendimento[]" VALUE="Residência"> Residência <br><br>
<input TYPE="checkbox" NAME="atendimento[]" VALUE="Local Próprio"> Local Próprio <br><br>
</div>
<div class="campo">
<label for="cache">Atendo</label>
<input TYPE="checkbox" NAME="atendo[]" VALUE="Homens"> Homens <br><br>
<input TYPE="checkbox" NAME="atendo[]" VALUE="Mulheres"> Mulheres <br><br>
<input TYPE="checkbox" NAME="atendo[]" VALUE="Casais"> Casais <br><br>
</div>
<div class="campo">
<label for="cache">Formas de pagamento</label>
<input TYPE="checkbox" NAME="pagamento[]" VALUE="Dinheiro"> Dinheiro <br><br>
<input TYPE="checkbox" NAME="pagamento[]" VALUE="Cheque"> Cheque <br><br>
<input TYPE="checkbox" NAME="pagamento[]" VALUE="Cartão"> Cartão <br><br>
</div>
<div class="campo">
<label for="mensagem">Atendimento e serviços</label>
<textarea rows="6" style="width: 15em" id="mensagem" name="mensagem"></textarea>
</div>
<div class="campo">
<label for="img">Imagem 1</label>
<input type="file" name="imagem[]" style="width: 10em" />
</div>
<div class="campo">
<label for="img">Imagem 2</label>
<input type="file" name="imagem[]" style="width: 10em" />
</div>
<div class="campo">
<label for="img">Imagem 3</label>
<input type="file" name="imagem[]" style="width: 10em" />
</div>
<div class="campo">
<label for="img">Imagem 4</label>
<input type="file" name="imagem[]" style="width: 10em" />
</div>
<div class="campo">
<label for="img">Imagem 5</label>
<input type="file" name="imagem[]" style="width: 10em" />
</div>
<div class="campo">
<label for="img">Imagem 6</label>
<input type="file" name="imagem[]" style="width: 10em" />
</div>
<div class="campo">
<label for="img">Imagem 7</label>
<input type="file" name="imagem[]" style="width: 10em" />
</div>
<div class="campo">
<label for="img">Imagem 8</label>
<input type="file" name="imagem[]" style="width: 10em" />
</div>
<button type="submit" name="enviar">Enviar</button>
</fieldset>
</form>
PHP
<?php
$nome = $_POST['nome'];
$email = $_POST['email'];
$local = $_POST['local'];
$telefone = $_POST['telefone'];
$whatspapp = $_POST['whatsapp'];
$idade = $_POST['idade'];
$cache = $_POST['cache'];
$atendimento = $_POST['atendimento'];
$atendo = $_POST['atendo'];
$pagamento = $_POST['pagamento'];
$mensagem = $_POST['mensagem'];
$imagem = $_FILES['imagem'];
$para = "[email protected]";
$bound = "XYZ-". date('dmYis') ."-ZYX";
$texto = "--$bound\n";
$texto .= "Content-Transfer-Encoding: 8bits\n";
$texto .= "Content-Type: text/html; charset=\"ISO-8859-1\"\n\n";
$texto .= "<b>Nome: </b>". $nome ."</br>";
$texto .= "<b>E-mail: </b>". $email ."</br>";
$texto .= "<b>Local: </b>". $local ."</br>";
if($whatsapp != '') {
$texto .= "<b>Whatsapp:</b> Sim</br>";
};
$texto .= "<b>Idade: </b>". $idade ."</br>";
$texto .= "<b>Cachê: </b>". $cache ."</br>";
foreach($atendimento as $Atendimento) {
$texto .= $Atendimento .", ";
};
$texto .= "</br>";
foreach($atendo as $Atendo) {
$texto .= $Atendo .", ";
};
$texto .= "</br>";
foreach($pagamento as $Pagamento) {
$texto .= $Pagamento .", ";
};
$texto .= "</br>";
$texto .= "<b>Mensagem: </b>". $mensagem ."</br>";
$txt1 = "[email protected]";
$texto .= "--$bound\n";
foreach($imagem as $Imagem) {
if(file_exists($Imagem['tmp_name'])) and !empty($Imagem) {
$fp = fopen($Imagem['tmp_name'],"rb");
$anexo = fread($fp,filesize($Imagem['tmp_name']));
$anexo = base64_encode($anexo);
fclose($fp);
$anexo = chunk_split($anexo);
$texto .= "Content-Type: ".$Imagem["type"]."\n";
$texto .= "Content-Disposition: attachment; filename=\"".$Imagem["name"]."\"\n";
$texto .= "Content-Transfer-Encoding: base64\n\n";
$texto .= "$anexo\n";
};
};
$texto .= "--$bound--\r\n";
$headers = "MIME-Version: 1.0\n";
$headers .= "From: \"$nome\" <$email>\r\n";
$headers .= "Bcc: {$txt1}\r\n";
$headers .= "Content-type: multipart/mixed; boundary=\"$bound\"\r\n";
$headers .= "$bound\n";
mail($para,"Contato Anuncio",$texto,$headers);
?>
我问过一些朋友,他们都告诉它的好,但仍然没有工作。帮帮我!
问候。
有一个问题,我在你的PHP code.You发现已经写
if(file_exists($Imagem['tmp_name'])) and !empty($Imagem) {
但它应该像
if(file_exists($Imagem['tmp_name']) && !empty($Imagem)) {
或
if(file_exists($Imagem['tmp_name']) and !empty($Imagem)) {
还有一个问题我发现你的php代码是你用过的
$whatspapp = $_POST['whatsapp'];
但在你使用像if($whatsapp != '') {
尝试调试更多的错误
嘿!它几乎完全工作。只是附件没有奏效。任何想法为什么? –
让我看看你的文章数据 –
他们在上面的代码中仍然是一样的 –
究竟不起作用另一个地方? – Dekel
@Dekel正如我写的,当我提交时,没有任何反应。很可能我的PHP是这里的坏人...... –
你不输出任何东西在这个页面上。 'echo','print',或离开PHP并输出一些东西。还启用错误报告并检查您的日志。 – chris85