问题描述:

the contact form this with the following error:

Variable passed to each() is not an array or object

but the email comes in white, without it, without name and without the recipient of the email, what could be wrong?

index.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Enviando email pelo PHP Através de um formulário</title>

</head>

<body>

<form action="formulario.php" method="POST">

Seu nome: <input type="text" name="nome"><br>

Seu e-mail: <input type="text" name="email"><br>

Comentários: <textarea name="comentarios"></textarea><br>

<input type="submit" value="Enviar">

</form>

</body>

</html>

formulario.php

<?PHP

// Set the message that will be sent to your e- mail below:

$mensagem = "Mensagem enviada em ".date("d/m/Y").", os dados seguem abaixo:\n";

// This loop puts all the form fields in the e- mail message to be sent

while(list($campo, $valor) = each($HTTP_POST_VARS)) {

$mensagem .= ucwords($campo).": ".$valor."\n";

}

// Now we will make PHP send the form data to your email :

mail("[email protected]", "Assunto do E-mail", $mensagem, "From: $REMOTE_ADDR");

echo "Seu e-mail foi enviado com sucesso. Obrigado";

?>

网友答案:

$HTTP_POST_VARS is deprecated and no longer supported. Use $_POST or $_REQUEST instead...

相关阅读:
Top