| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
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? |
|
|
|
|
|
#2 (permalink) |
|
shiro
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.
|
|
![]() |