Sending Email Form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
millsy007
Forum Commoner
Posts: 78
Joined: Wed Jul 02, 2008 7:00 pm

Sending Email Form

Post by millsy007 »

Hi
I have some code that sends a form:

Code: Select all

 
$name = trim($_GET['name']); //The senders name
$email = trim($_GET['email']); //The senders email address
$subject = trim($_GET['subject']); //The senders subject
$message = trim($_GET['msg']); //The senders message
 
mail($to,$subject,$message,"From: ".$email.""); //a very simple send
 
It works fine but I am trying to make some changes to it but when I do it stops working :(

What I want to do is change the subject of the email to say 'Enquiry'
And have the subject text that is passed in be added as part of the message (this will actually hold the users brief summary)
Any help would be appreciated as my attempt didnt send the mail.
Last edited by Benjamin on Wed May 20, 2009 6:58 pm, edited 1 time in total.
Reason: Added [code=php] tags.
User avatar
deejay
Forum Contributor
Posts: 201
Joined: Wed Jan 22, 2003 3:33 am
Location: Cornwall

Re: Sending Email Form

Post by deejay »

this is what i'd try -

Code: Select all

 
$name = trim($_GET['name']); //The senders name
$email = trim($_GET['email']); //The senders email address
$subject = 'Subject:';
$subject_to_add = trim($_GET['subject']); //The senders subject
$message = trim($_GET['msg']); //The senders message
$message = "$subject_to_add  
 
$message";
 
hope that helps.
Last edited by Benjamin on Wed May 20, 2009 6:58 pm, edited 1 time in total.
Reason: Changed code type from text to php.
millsy007
Forum Commoner
Posts: 78
Joined: Wed Jul 02, 2008 7:00 pm

Re: Sending Email Form

Post by millsy007 »

Thanks, but doesnt seem to work, is there something missing from:

Code: Select all

$message = "$subject_to_add  
 
$message";
Last edited by Benjamin on Wed May 20, 2009 6:59 pm, edited 1 time in total.
Reason: Changed code type from text to php.
Post Reply