473,466 Members | 1,455 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

recommendation for a good mail form?

Hello,
Can anyone recommend a simple PHP script for taking the contents of
a form and emailing it to an address defined within the PHP script? I
have downloaded a couple via Google, but they're not quite what I'm
looking for.

Thanks for your advice, - Dave

Jul 17 '05 #1
2 1478
la***********@zipmail.com wrote:
Hello,
Can anyone recommend a simple PHP script for taking the contents of
a form and emailing it to an address defined within the PHP script? I
have downloaded a couple via Google, but they're not quite what I'm
looking for.

Thanks for your advice, - Dave


Hi Dave,

Just use the buildin function mail() in PHP.
And use $_POST["somevar"] to read the postingsvars.

CHeck www.php.net for details on mail().

Regards,
Erwin Moller
Jul 17 '05 #2
DH
la***********@zipmail.com wrote:
Hello,
Can anyone recommend a simple PHP script for taking the contents of
a form and emailing it to an address defined within the PHP script? I
have downloaded a couple via Google, but they're not quite what I'm
looking for.

Thanks for your advice, - Dave


IMHO, the following works well as an "include file" for various Contact
Us forms on my client's web sites.

function valid_email($email)
{
if(empty($email)){

return false;
}elseif(eregi("^[0-9a-z]([-_.+]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,7}$",
$email)){

return true;

}

return false;
};

$opts['admin_email'] = 'a****@domain.com';

$opts['admin_name'] = 'Some One';

$opts['owner_email'] = 'o****@domain.com';

$msg = '';

// Disallow certain HTML INPUT names from appearin in email messages

$omit_field_name_array = array('s', 'submit');

if(!isset($subj)){

$subj = str_replace('www.', '', $_SERVER['HTTP_HOST']).' web site
feedback';

}

while(list($key, $val) = each($_POST)){

if($val != '' && !in_array($key, $omit_field_name_array)){

$new_key = str_replace('_', ' ', $key);

$msg .= ucwords($new_key).':
'.stripslashes(trim(strip_tags($val)))."\n\n";

}

$$key = stripslashes(trim(strip_tags($val)));

# Debug
# echo "\n".$key.' = '.$val.'<br>';
# exit;

}

$lf = isset($_SERVER["COMSPEC"])
&& stristr($_SERVER["COMSPEC"], 'windows')
? "\r\n" : "\n";

if($msg != ''){

$msg .= 'Submitted: '.date('r')."\n";

if(valid_email($email)){

$hdr = 'From: <'.$email.'>'."$lf"
.'Reply-To: '.$email."$lf"
.'Return-Path: '.$email."$lf"
.'X-Mailer: PHP '.phpversion()."$lf"
.'X-Priority: 3'."$lf"
.'X-Sender: '.$email;
}else{

$hdr = 'From: "'.$opts['admin_name'].'"
<'.$opts['admin_email'].'>'."$lf"
.'Reply-To: '.$opts['admin_email']."$lf"
.'Return-Path: '.$opts['admin_email']."$lf"
.'X-Mailer: PHP '.phpversion()."$lf"
.'X-Priority: 3'."$lf"
.'X-Sender: '.$opts['admin_email'];

}

$msg .= "{$lf}--{$lf}{$opts['admin_name']}{$lf}Site
Administrator{$lf}{$opts['admin_email']}";

$opts['owner_email'] != $opts['admin_email'] ? $hdr .= "{$lf}BCC:
{$opts['admin_email']}" : '';

$sent = @mail($opts['owner_email'], $subj, $msg, $hdr);

if(!($res = @mysql_query(sprintf("INSERT INTO feedback (name, email,
subj, comments)
VALUES ('%s', '%s', '%s', '%s')",
addslashes($name),
$email, addslashes($subj),
addslashes($msg))))){

$opts['admin_msg'] = $_SERVER['PHP_SELF'].' did not insert
feedback on '.$_SERVER['HTTP_HOST'];

}

}
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: C. Smith | last post by:
I am technical advisor for a new group of middle-aged people that want to create a web site for historical information about our local area. They want to scan in a lot of old photos, include...
5
by: D. Alvarado | last post by:
Hello, DOes anyone have a recommendation for some free code to send out HTML-formatted emails? The code does not have to be cross-browser compatible. Thanks for any advice, - Dave
36
by: Peter Brause | last post by:
Hello, my stylesheet shows different colors for visited, active and hovered links. It works fine in IE 6, but in Opera 7 the color for the active link (red background) is never shown. How to...
9
by: Rick Cook | last post by:
I would like to do a response form on one of my sites instead of posting an e-mail address for spammers. I've taken a couple of examples from sites, but the code looks clunky and non-conformant to...
13
by: Gabriel Reid | last post by:
Greetings, I'm looking for any books that the members of this group may have to recommend for C#. I have experience with a number of programming languages (probably most relevant would have to...
16
by: Robert Zurer | last post by:
Can anyone suggest the best book or part of a book on this subject. I'm looking for an in-depth treatment with examples in C# TIA Robert Zurer robert@zurer.com
1
by: yoni | last post by:
I'm need recommendation for a good WYSIWYG asp.net editor control to allow web site content managment dynamically. thanks for your help.
11
by: Larry | last post by:
I will be teaching an eCommerce application development course using ASP.Net after many years of having taught classic ASP. (Course was interrupted by 18 months in the Middle East with my Army...
6
by: Andrew Poulos | last post by:
I need to create a treeview control with the following options: - expand/collapse all - the small plus/minus images next to nodes that can expand/collapse - assign images to each node -...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.