View Single Post
Old 28-08-2005, 15:16   #3 (permalink)
Cborrow
I like code.
 
Join Date: Dec 2004
Location: Chesapeake, VA
Posts: 243
Send a message via AIM to Cborrow
Here is a simple contact form that takes you to another page. It should give you an idea on how to
make one with PHP. Or you can also go to www.hotscripts.com or something similar to download a free contact form script.

PHP Code:
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
<p>
Name: <input type="text" name="name" size="20" /><br /><br />
Email: <input type="text" name="email" size="20" /><br /><br />
Website: <input type="text" name="website" size="20" /><br /><br />
Message:<br />
<textarea name="message" cols="25" rows="5"></textarea><br /><br />
<input type="submit" name="submit" value="Submit" />
<input type="reset" nam="reset" value="Reset" />
</p>
</form>
<?php
    
if(isset($_POST['submit'])) {
    
$to "Your email address"//Email address you want all messages to be sent to
    
$subject "Your subject"//Subject on all email's
    
$name $_POST['name'];
    
$email $_POST['email'];
    
$website $_POST['website'];
    
$message $_POST['message'];
    
    
$content "You have received a message from your contact from, with the following message.\n\n Name: $name\n Email: $email\n Website: $website\n Message: $message";

    if(!
$name) {
    echo 
"You forgot to enter a name, please go back and enter one"; exit;
    }
    if(!
$email) {
    echo 
"You forgot to enter an email address, please go back and enter one"; exit;
    }
    if(!
$website) {
    echo 
"You forgot to enter a website address, please go back and enter one"; exit;
    }
    if(!
$message) {
    echo 
"You forgot to enter a main message, please go back and enter one"; exit;
    }
    else {    
    
mail($to$subject$content);
    
header("Location: thankyou.html");
    }
    }
?>
  Reply With Quote