Old 07-06-2008, 17:32   #1 (permalink)
aslanandbeez
Registered User
 
Join Date: Nov 2007
Posts: 6
php mailing assistance please?

Okay I'm doing the whole email form thing on my site, and I want the name and email address from the form to go into the header, here's my code

<?php

$to = 'culturaldissection@hotmail.com';
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$headers = 'From: $name $email' . "\r\n" .
'Reply-To: $email' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
echo "Your message has been sent, thank you";

?>


Also I'm hoping to adapt this for an e-card service, so would I have to put the selected card and a message into a function called $content for instance then do something like;

$message = '$content';

or am I on completely the wrong track?
  Reply With Quote
Old 07-06-2008, 20:47   #2 (permalink)
haku
shiro
 
haku's Avatar
 
Join Date: Aug 2007
Location: Yokohama, Japan
Posts: 2,070
Did you try it out before asking here? Testing is the best way to find if something works.

There is one big thing you are missing here though - you are putting the form input directly into the mail, without cleaning it first. This leaves open a huge possibility of people injecting nasty code into your form, and sending out spam mails and stuff in your name. You should research injection attacks with email forms a little, and you will find out how to protect against that kind of stuff.

(note: it would have been sent with what you have)
__________________
This space for rent.
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8