PDA

View Full Version : Look at my PHP


cobbweb
February 18th, 2006, 08:01 PM
the following code is saved as an HTML file called feedback.html


<html>
<body>
<form method="post" action="sendmail.php">
Email: <input name="email" type="text" /><br />
Message:<br />
<textarea name="message" rows="15" cols="40">
</textarea><br />
<input type="submit" />
</form>
</body>
</html>




Then I have this PHP file called sendmail.php that has this code.


<?
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;

mail( "thenetduck@gmail.com", "Feedback Form Results",
$message, "From: $email" );
header( "Location: http://bilbob60.freecoolsite.com/thankyou.html" );
?>



You can view the page at http://bilbob60.freecoolsite.com/feedback.html

The Problem that im having is, when i fill out the information, i never recieve an email. Do i need some type of server or somthing? As you probably assumed, im learning PHP. Any ideas on why I dont recieve an email with the information filled out? Maby if you do a test and try using that form to email me it will work. Anyhelp is much needed
Thanks,
Cobbweb

sapo
February 18th, 2006, 08:09 PM
You are missing the headers i think.. this works for me:

$mensagem = '<html>
<head>
<title>BR IMPORT</title>
</head>
<body>
<table>' .
$msg . '
</table>
</body>
</html>';

$headers = 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n";
/* headers adicionais */
$headers .= 'To: ' . $cliente . ' <' . $destino . '>' . "\n";
$headers .= 'From: Me <someemail@somedomain.com>' . "\n";
mail($destino,$assunto,$mensagem,$headers)

But you should read more about php mail, and more about headers, my code will send a html message.. for a text file it would be different.

vibes
February 18th, 2006, 08:49 PM
sapo is right edit your headers, also i would change $_REQUEST to $_POST and maybe code in a few checks or someone will endup abusing your server

Enter
February 19th, 2006, 08:29 AM
are you testing it on localhost? or on some hosting? a lot of hostings are disabling the mail(); function for security reasons

fakey1223
April 26th, 2006, 05:24 PM
To get the php mail() function working, I installed the sendmail package (doing so removed postfix).

LordHunter317
April 26th, 2006, 10:16 PM
also i would change $_REQUEST to $_POSTAdds no security.

and maybe code in a few checks or someone will endup abusing your serverThere's no way to abuse the server in this manner besides spam himself.

To get the php mail() function working, I installed the sendmail package (doing so removed postfix).There's no reason to do this. Postfix is sendmail-compatible.