PDA

View Full Version : help with a PHP contact form


fatigue
February 8th, 2005, 05:35 PM
Hi,
I have to say that i'm quite new with PHP and i don't know much about it. But since i was looking for to add a contact form to my website, so i've found an prety simple one, with just one .php file. The main issue, i have with it, is that when you submit a message, the only information i get in my webmail, is the email address and the message of the sender.
I was wondering if there would be anyone who would know how to modify and maximize the code so that not only the email add and the message can be displayed, but also the name and the subject that the sender has filled ( and no longer the "contact" subject as specified in the php file).
I hope that i've made it clear.
I've found the whole contact form from this site. (http://www.zymic.com/view_tutorial.php?id=87)

thanx for the help.
Fatigue.

ps: i'm also looking for a password authentication form, i've found several tutorials about that, but i've failed to understand anything :raphael:. Since i don't know if my host supports apache, i don't want to risk and use .htaccess , i'd much prefer php. I didn't want to post a new thread about that so i thought i might ask that too in here.

Thanx a lot.

degsy
February 8th, 2005, 06:09 PM
Hi,

There are a few errors in the script


$message1 = "from: $name\nemail: $email\nmessage:\n$msg1";
mail($youremail, $subject, $msg, "From: $email\r\nReply-to: $email\r\n");


Change to

$message1 = "from: $name\nemail: $email\nmessage:\n$msg";
mail($youremail, $subject, $message1, "From: $email\r\nReply-to: $email\r\n");



If you want to change the Subject you can do something like
$subject = "New Message from $name";

Or if you want to let the user add a subject then add a new input to the form
Subject <input type="text" name="subject"><br/>
and remove the $subject = line from the php code



There are still a few problems with the script in security terms such as no email validation.

Checkout these scripts
http://www.xentrik.net/php/email.php
http://www.xentrik.net/php/mailform.php


Also, where this script uses 3 pages it could be all moved into 1 page.