/    Sign up×
Community /Pin to ProfileBookmark

contact form not showing email-addresses

I want to create a contact form with a dropdown selection menu where people can select a different department and when they send it, the message needs to go automaticaly to the email-addresse (which is linked to a selection from the dropdown menu). the emailaddresses are not to be shown.

Who can I do this? I have no experience with that so if anybody could help me with it, it would be great.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@SheldonSep 28.2007 — Here is a quick example with very little error checking just to help you on your way.

[code=php]<?php

session_start();
// This is a basic version

$message = "Contact Us";

if(!empty($_POST['form_submit'])){

if(!empty($_SESSION['email'])){
$today = date("r");
$sendto = trim($_POST['sendto'])."@domainname.com";
$email = $_POST['email'];
$name = $_POST['name'];
$content = $_POST['content'];
$headers = "FROM {$email}";
$subject = "Contact From {$name}";
$message = "{$name} - {$email}nn{$commtent}nn{$today}";
mail($sendto,$subject,$message,$headers) or die ("Mail Could not be sent.");
$display = "You message gas been send.";
$_SESSION['email'] = "true";
}else{
$display = "You can only send mail once";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

<title>Mail Form</title>

</head>

<body>

<h1><?php echo($display); ?></h1>

<form action="<?php echo(htmlentities(basename($_SERVER['PHP_SELF']))); ?>" method="post" accept-charset="utf-8">
<p>Send to: <select name="sendto">
<option value="info">Info</option>
<option value="support">Support</option>
<option value="bill">Bill</option>
<option value="sally">Sally</option>
</select></p>

<p>Name:<input type="text" name="name" /></p>
<p>Email:<input type="text" name="email" /></p>

<p>Comments:<textarea name="content"></textarea></p>

<input type="hidden" name="form_submit" value="true" />

<p><input type="submit" value="Continue &rarr;"></p>
</form>

</body>
</html>
[/code]
*Untested
×

Success!

Help @UD2006 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...