I am very new to using PHP. This is the first thing I've tried with it. My form works and sends the e-mail, but the only field that's populated in the message is the name field. I have 4 other fields that need to be there. I have read the php manual and that didn't help. I've also done extensive research on the net and read all the posts I could find here about working with mail forms.
What I'm doing is using an html form and a php script to run it. As I said, the message goes through, but with only the one field populated. I know that is because I've only told it to populate that one field, but I'm not sure how to get the others to populate.
I've also tried adding them to the the mail string alone, tried adding them to the initial methods after the mail server information alone, tried adding them to both the initial methods and the mail string which didn't work either.
If someone could help me, I'd appreciate it. I am so frustrated and have no idea where to turn.
<?php
ini_set("SMTP","mail.mailserver.com");
ini_set("sendmail_from","someone@domainname.com");
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
if (!isset($_REQUEST['email'])) {
header( "Location: http://www.domainname.com/contact.html" );
}
elseif (empty($name) || empty($email)) {
header( "Location: http://www.domainname.com/error.html" );
}
else {
mail( "someone@domainname.com", "Suject Line",
$name, "From: $email" );
header( "Location: http://www.domainname.com/thanks.html" );
}
?>
As I said, the message is sent but my other fields are all missing. Just the name is in the body. Obviously, I have all the server information entered correctly, but don't have a clue how to add fields without blowing this up.
The other thing is I want the name and email fields to be required (which works), but that is not necessary for the other fields. I did have a thought that if I made all fields required, it might work, but I hate to do that.
I have another question too. Would it be better to use the POST method rather than the REQUEST method since my form uses POST or does that make a difference?