Hi, I am attempting to connect a form in Dreamweaver to an email account via a ftp webspace. I have the following generic code, (HTML form and PHP mail file) but I am not receiving emails... Would anyone have an idea of what I have done wrong and/or provide any insight to correct this problem?? Thank you in advance.

html form file

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<body>

<form method="post" action="sendmail.php">
  Email: <input name="email" type="text" /><br />
  Message:<br />
  <textarea name="message" rows="15" cols="40">
  </textarea><br />
  <input type="submit" />
</form>
</body>
</html>

php file to send mail

<?php
  $email = $_REQUEST['email'] ;
  $message = $_REQUEST['message'] ;

  mail( "pro7908@setonhill.edu", "Feedback Form Results",
    $message, "From: $email" );
  header( "Location: http://www.setonhill.edul" );
?>

Recommended Answers

All 4 Replies

Because you use

#
<form method="post" action="sendmail.php">

This is the way to store the values;
$email = $_POST ;
$message = $_POST ;

I tried that and Im still not getting it to work...

I don't see any ftp or dreamweaver relevant code here but i will build you a new code which works brilliantly for me.
you need to specify a content type for html coding to work.
and an id tag to retrieve the post variables

feedback form

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Feedback Form</title>
</head> 
<body> 
<form method="post" action="sendmail.php"> 
 Email: <input id="email" name="email" type="text" /><br />  
Message:<br />  <textarea id="message" name="message" rows="15" cols="40">  </textarea><br />  <input type="submit" />
</form></body></html>

sendmail.php

if (isset($_POST['email'])){
/* Email Variables */

$emailSubject = 'feedback form results';
$webMaster = 'pro7908@setonhill.edu';


/* Data Variables */

$email = $_POST['email'];
$message = $_POST['message'];



$body = <<<EOD
<br><hr><br>
Email: $email <br>

Message: $message<br>
EOD;


$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body,
$headers);


/* Results rendered as HTML */

$theResults = <<<EOD
<html>
<head>
<title>sent message</title>
<meta http-equiv="refresh" content="1;URL=http://www.setonhill.edul/">
<style type="text/css">
<!--
body {
background-color: #000;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 20px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #CCC;
text-decoration: none;
padding-top: 200px;
margin-left: 150px;
width: 800px;
}

-->
</style>
</head>
<div align="center">Your message has been received!<br />
You will return to The our home page shortly</div>
</div>
</body>
</html>
EOD;
echo "$theResults";
}
else {
	$theResults = <<<EOD
<html>
<head>
<title>sent message</title>
<meta http-equiv="refresh" content="1;URL=http://www.setonhill.edul/">
</head>

</div>
</body>
</html>
EOD;
echo "$theResults";
}
?>

you should modify it to suit plus i would suggest using spry validation to check email is an email or people can get you in a lot of trouble. also it helps to prevent php injection.
to insert spry click insert ->
form ->
spry validation text field
once inserted click on the box and change properties type -> email
required and enforce pattern.
hope this helps :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.