Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1377 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Marketplace     Looking For / Wanting to Sell Products     Other Digital Goods :

PHP Contact Script

Thread title: PHP Contact Script
     
    Thread tools Search this thread Display Modes  
Prev Previous Post   Next Post Next
12-10-2006, 09:04 PM
#1
Andrew R is offline Andrew R
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
 
Posts: 5,200
iTrader: 17 / 95%
 

Andrew R is on a distinguished road

  Old  PHP Contact Script

Hey, just made this for one of my sites, so I thought I'd let you guys use it.

PHP Code:
<?php
if (isset($_POST['submit'])) {
    
// Just make all the info good to work with
    
$to "admin@example.com";
    
$subject "Example.com Contact Form";
    
$name trim(stripslashes($_POST['name'])); 
    
$email trim(stripslashes($_POST['email'])); 
    
$message trim(stripslashes($_POST['message']));
    
$reason ucfirst($_POST['reason']);

    
// Check all fields for values
    
$error false;
    if (
trim($name) == "")
        
$error true;
    if (
trim($email) == "")
        
$error true;
    if (
trim($message) == "")
        
$error true;
    if (
$error == true) {
         echo 
"<span class=\"error\">One of the fields has been left blank. Please fill out all fields and try again.</span>\n";
    } else {
        
// Make the email all pretty
        
$body "Name: ".$name."\n";
        
$body .= "Email: ".$email."\n";
        
$body .= "Reason for Contact: ".$reason."\n";
        
$body .= "Message:\n".$message;
        
// Headers (thank you Patrick Paul)
        
$headers  "MIME-Version: 1.0\n";
        
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
        
$headers .= "X-Priority: 3\n";
        
$headers .= "X-MSMail-Priority: Normal\n";
        
$headers .= "X-Mailer: php\n";
        
$headers .= "From: ".$email."\n";
    

        
// Send Email
        
$sent mail($to$subject$body$headers);

        
// Print results
        
if ($sent) {
            echo 
"<p>Your email has been sent. Please allow time for a reply.</p>\n";
        } else {
            echo 
"<span class=\"error\">There has been an error while trying to send your email. Manually send an email to the webmaster to have this problem corrected.</span>\n";
        }
    }
}
?>
Code:
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
	<p>Name:</p>
	<input type="text" name="name" />
	<p>Email:</p>
	<input type="text" name="email" />
	<p>Reason for contact:</p>
	<select name="reason">
		<option name="1" value="support">Support</option>
		<option name="2" value="feedback">Feedback</option>
		<option name="3" value="feature request">Feature Request</option>
	</select>
	<p>Message:</p>
	<textarea name="message" rows="6" cols="40"></textarea>
	<p><input type="submit" name="submit" value="Submit Form" /></p>
</form>

     


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed