Forum Moderators: coopster

Message Too Old, No Replies

Simple PHP mail script problem

         

crak_bot

12:23 am on Sep 5, 2006 (gmt 0)

10+ Year Member



Hello,

I am trying to put up a simple contact form and use a php script to handle it. I have no knowledge of PHP at all so bear with me. The current script is.

<?
$ForwardTo="info@mydomain.com";
$email=$_REQUEST['email'];
$entry=$_REQUEST['phone'];
$subject=$_REQUEST['message'];
mail($ForwardTo, "Web Submission", $email, $phone, "From:info@mydomain.com");
header("Location: thankyou.html");
?>

I end up getting these e-mails fine but my form has a third text area named "message" but no matter what I add to the script to try to include the text in the "message" area the e-mail never makes it to me so I assume I am not setting up the script right.

My question is. What do I need to add to the above script so that the content of a third text area named message gets to me in the email created.

Thanks

smatts9

1:18 am on Sep 5, 2006 (gmt 0)

10+ Year Member



Use it this way:

mail($to, $subject, $body)

$to = what email address to mail to.
$subject = subject line of email.
$body = whatever text within the email.

barns101

9:37 am on Sep 5, 2006 (gmt 0)

10+ Year Member



Using your existing code, it should be like this:


<?php
$ForwardTo="info@mydomain.com";
$email=$_REQUEST['email'];
$entry=$_REQUEST['phone'];
$subject=$_REQUEST['message'];
mail($ForwardTo, "Web Submission", "$email\n\n$phone\n\n$subject", "From:info@mydomain.com");
header("Location: thankyou.html");
?>

The "\n\n" adds new lines to make the content of the email a little easier on the eye! ;)

crak_bot

12:59 am on Sep 6, 2006 (gmt 0)

10+ Year Member



Hello,

Thanks for the replies. The script is up and running and thanks for tip about the added line entry.

It was getting frustrating just using trial and error, meaning I would change the script, upload it, then visit the site and fill out the form and wait for an e-mail.

cybersphere

2:09 am on Sep 6, 2006 (gmt 0)

10+ Year Member



I was just having a look at the mail function this morning, and decided that it was inadequate for my needs, since it couldn't perform SMTP authentication.

PHPMailer is a better, all-round solution. [phpmailer.sourceforge.net...]