Jump to content

Add A Contact Us Or Feedback Form


podarum
 Share

Recommended Posts

Do you know if your hosting company has PHP enabled? You can have a form perform a mailto, but that is considered an ugly way of doing it when you can have your server send the email. Having the server do it means that the user doesn't need to have an e-mail account set up on the computer/browser they are visiting your site on.

Link to comment
Share on other sites

No, you can create the form on Dreamweaver, you just set the action to the appropriate php script, and in the script deal with the e-mail. Here is my form code and php:HTML:

<form method="post" action="do_mailto.php"><fieldset><legend>Contact Form</legend><label for="email">Your e-mail address:</label><input type="text" id="email" name="email" size="20" maxlength="150" /><br /><label for="subject">Subject:</label><input type="text" id="subject" name="subject" size="20" maxlength="150"  /><br /><label for="messageBody">Comments:</label><textarea cols="30" rows="8" id="messageBody" name="messageBody" ></textarea><br /><input type="submit" name="send" value="send" /></fieldset></form>

PHP:

<?phpif(!$_POST) {//send them awayheader("Location:somewhere_to_go.html");} else if(empty($_POST["email"]) || empty($_POST["body"])){  header("Location:somewhere_to_go.html");} else {    //send mail  $headers  = "MIME-Version: 1.0 \r\n";$headers .= "Content-type: text/html; charset=iso-8859-1 \r\n";$headers .= "To: e-mail \r\n";$headers .= "From: $_POST["email"] \r\n";$to = "your@email.com";$subject = "E-mail from: $_POST["email"]";  $msg = "From: $POST["email"] \r\n";  $msg .="Subject: $_POST["subject"[ \r\n";  $msg .= "Message: \r\n$POST["body"] \r\n";// Mail itmail($to, $subject, nl2br($msg), $headers);  header("Location: send_them_somewhere.html");}?>

That's the bare bones but if you're the only one seeing the message, then that's enough really. You can add more fields to the form to ask for different info or whatever, obviously.

Link to comment
Share on other sites

Anywhere you want - the first two are in case the form isn't filled out properly, so you can send them back to the form, and the last one is where you want the user to end up after they submit the contact form.

Link to comment
Share on other sites

You're very welcome

Link to comment
Share on other sites

The code for the redirect after a few seconds is:<meta http-equiv="refresh" content="4;url=somewheretogo.html" />The number `4` can be swapped for the delay in seconds, and it doesn't have to be an integer (I don't think).So, at the end of the php page that processes the email, the last header("Location: here.html"); should send them to your confirmation page, and the confirmation page should have the above line in it, either between the head tags of the page or after the </html> tag and the address can be where you want.

Edited by chibineku
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...