Site

Resources

Tutorials

Graphics

Webdesign

This will let you have a contact form on your site without having to use a third party like Bravenet.

First we start with the php part. I didn't write this part, it is courtesy of David from HTMLite.

Copy and paste the code into Notepad. Instructions are in this code but I'll tell you anyways: change what is in pink to reflect your own email address and your own thank you page.

Then save it as a php file. For the purpose of this example we will call it contact.php.

Once you upload its, CHMOD it to 755.

<?php

// Enter your own email here for a default value.
$default = "email@yourdomain.com";

// The only other thing that needs changing is the last line showing the thank you page to be directed to after the visitor submits the form.

// After you edit, save, and upload this file to online, CHMOD it to 755.

// On your form page, if you have one of the values set to "email" or "subject", that will be used as the responder email and email subject line. Otherwise a default value will appear automatically.

// Loop to gather form information
$message = "The following information has been sent.\n\n";
if ($_POST){
while (list($lvar,$lvalue) = each($_POST)){
if (!empty($lvalue) && $lvar!="from" && $lvar!="subject" && $lvar!="submit" && $lvar!="Submit" && $lvar!="submit_x" && $lvar!="submit_y") {$message .= "$lvar\n$lvalue\n\n";}}}
// toast the quotes
$message = stripslashes($message);
// if EMAIL null, then set default to recipient value
if (!$from) $from = $default;
$from = "From: " . $from;
if (!$to) $to = $default;
// if SUBJECT null, then set default
if (!$subject) $subject = "Form results entered";
// Send the info out
mail($to,$subject,$message,$from);

// Redirect to a ThankYou page. Change the page filename as desired.
header("Location: thankyou.php");

?>

1 2
Not Ashamed Webband

My projects

Consider Giving

Links

Link Exchange

Stats