PDA

View Full Version : simple php mail me



g_force
09-30-2008, 08:30 PM
For some reason I'm having trouble getting a simple php form to mail me some data. Here is what I was using but have since been told that it isn't practical and needs updating:


<script language="php">
$email = $HTTP_POST_VARS[email];
$mailto = "my.email@myhost.com";
$mailsubj = "Title";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Data received:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS)) { $mailbody .= "$key : $val\n"; }
if (!eregi("\n",$HTTP_POST_VARS[email])) { mail($mailto, $mailsubj, $mailbody, $mailhead); }
</script>

Does anyone have any suggestions?

++ don't be put off by my lack of thanks - I don't know how to give it// but thanks anyway

Nile
10-01-2008, 01:05 AM
Well, you really should use $_POST instead of $HTTP_POST_VARS, of course, I don't know what that is - (I assume its the same). And also use mail headers, learn a bit more here:
http://php.net/mail
The "Thank you" button is write under a user's post next the Quote, and other buttons, it looks some like the button below(this one isn't the clickable one).
http://www.dynamicdrive.com/forums/images/buttons/post_thanks.gif

magicyte
10-01-2008, 01:12 AM
Yeah. Nile's right. Use the $_POST variable. Also, that site he gave you is REALLY good. There is also this one site, W3Schools, that has an okay PHP e-mail script. Here it is: PHP E-mail (http://www.w3schools.com/php/php_mail.asp). Here is the secure form: PHP Secure E-mail (http://www.w3schools.com/php/php_secure_mail.asp)

-magicyte