← PHP

Ajuda formulário de contacto

Lida 3695 vezes

Offline

smiths 
Membro
Mensagens 101 Gostos 0
Feedback +2

Troféus totais: 21
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Level 4 Level 3 Level 2 Level 1 100 Posts 50 Posts 10 Posts

Bom dia a todos,

Sei pouco de php e precisava aqui de uma ajudita, aparentemente simples, com este formulário de contacto...

Código: [Seleccione]
<?php

while (list($key$val) = @each($_GET)) $GLOBALS[$key] = $val;
while (list(
$key$val) = @each($_POST)) $GLOBALS[$key] = $val;
while (list(
$key$val) = @each($_COOKIE)) $GLOBALS[$key] = $val;
while (list(
$key$val) = @each($_FILES)) $GLOBALS[$key] = $val;
while (list(
$key$val) = @each($_SESSION)) $GLOBALS[$key] = $val;

/* Subject and Email Variables */

$emailSubject 'Formulário de Contacto';
$webMaster 'destinatario@mail.com';

/* Gathering Data Variables */

$nameField $_POST['Name'];
$emailField $_POST['Email'];
$messageField $_POST['Message'];

$body = <<<EOD
<br><hr><br>
Name: 
$nameField <br>
Email: 
$emailField <br>
Message: 
$messageField <br>
EOD;

$headers "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success mail($webMaster$emailSubject$body$headers);

/* Results Rendered as HTML */

$theResults = <<<EOD
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><br />
<meta HTTP-EQUIV="REFRESH" content="0; url=obrigado.html">
<style type="text/css">
<!--
body {
background-color: #fffff;
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #000000;
text-decoration: none;
}
-->
</style>
</head>
<div align="left">
Redirecionando...</div>
</body>
</html>
EOD;
echo 
"$theResults";

?>

Ele funciona bem, só que no email recebido o remetente surge como desconhecido ("remetente desconhecido").  A ideia era que aparecesse o email ou o nome.

Obrigado
Offline

STronic 
Elite
Mensagens 546 Gostos 8
Feedback +5

Troféus totais: 30
Trófeus: (Ver todos)
Mobile User Search Apple User Super Combination Combination Topic Starter Poll Voter Level 5 Level 4 Level 3

Onde tens:
Código: [Seleccione]
$headers = "From: $email\r\n";
coloca:
Código: [Seleccione]
$headers = "From: $emailField\r\n";
Offline

smiths 
Membro
Mensagens 101 Gostos 0
Feedback +2

Troféus totais: 21
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Level 4 Level 3 Level 2 Level 1 100 Posts 50 Posts 10 Posts

Works like a charm  :obrigado: