okay, here we go some stuff to get you going, this will work as is but you'll want to change it probably...
html form: (if you have something like dreamweaver these are easy you normally just click a button and it sets up the different fields for you)
Code:
<form method="post" action="emailscript.php">
<p><select name="email">
<option value="morley">Mr Morley</option>
<option value="bod">Mr Bod</option>
</select></p>
<p><textarea name="emailbody" cols="50"></textarea></p>
<p><input type="submit" name="Submit" value="Submit"></p>
</form>
then you make a file called emailscript.php, basics, just have this in it:
Code:
<?
// the script will receive, from the above form, providing they are filled in:
// $email which would be either 'morley' or 'bod'
// $emailbody which is whatever they put in the text field.
// You need to change the email addresses. And when you change the
// variables that come through the script from the drop down menu
// you'll need to change the $email == "morley" bits as well.
if ($email == "morley") { $email_address == "my@emailaddress.com"; }
if ($email == "bod") { $email_address == "you@emailaddress.com"; }
// Set these as you want, the user will go to the thankyou page after,
// and the default emai laddress is just what the email will come 'from'
// even though the script is sending it. Helps it get through any
// spam filters you may have set up.
$website_default_emailaddress == "website@yourstie.com";
$thankyou_page == "http://www.yoursite.com/thank_you.php";
// simple email headers, again to help it get through spam filters.
$headers="From: Website <$website_default_emailaddress>\nReturn-Path: <$website_default_emailaddress>\r\nTo: $email <$email_address>\r\nReply-To: Website <$website_default_emailaddress>\n";
// Sets up what the user will receive i nthe email, currently it will read:
// User Entered: (2 line breaks) then whatever was entered i nthe text box.
$emailcontent == "User entered:\n\n".$emailbody;
// PHP mail() function, "email via Website" is the subject.
mail($email_address, "Email via Website", $emailcontent , $headers);
// sends the user to whatever you entered as the thankyou page earlier.
header("Location: $thankyou_page");
?>
topics to search on to improve this:
- PHP mail()
- html forms
- php variables
- php email scripts
basically by hidding the email address in the script a harvester cannot see it.
Bookmarks