NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page Simple Contact Form (UPDATED)

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search


Reply
 
LinkBack Thread Tools
Old 05-30-2006, 06:12 AM THREAD STARTER               #1 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics

Simple Contact Form (UPDATED)


This is an update of my Simple Contact Form script that I posted here which is very old and has many vulnerabilities.

(all functions pulled from my Domain Name Portfolio script )

Current Version: 1.0.7 (July 25, 2008)

Changelog:
1.0.7
-Removed option for HTML email
-Script now uses a config file 'sc_config.php' in 'sc_includes'
-There are other changes, but I can't recall everything.
-Cleaned up code and HTML

1.0.6
-Replaced current captcha with a whole new class and fonts
-Added a captcha image refresh
-Added new email headers
-Cleaned up code

1.0.5
-New constant, USE_HTML - if set to false, HTML won't be used for email.
-Added a new font "Acens.ttf" and removed one.
-New function to determine if the server has GD and freetype support.
-JS validation added to contact form (just checks if fields are empty atm)
-Overall code cleanup.

1.0.4
-New constant, USE_CAPTCHA - if set to false, CAPTCHA won't be used.
-Overall code cleanup.

1.0.3
-New constant, SPAM_NUM_LINKS, for the is_spam function.
-Added CAPTCHA (requires GD2 w/FreeType)

1.0.2
-Improved functions + the new 'is_spam' function
-New email headers (taken from phpBB's emailer class, and modified a tad)

1.0.1
-Functions file, with several functions to properly 'sanitize' input.
-Better error handling, and email validation regex
????: NamePros.com http://www.namepros.com/code/202512-simple-contact-form-updated.html
-Licensed under the GNU GPL

Attached (or you can download here: http://code.google.com/p/simple-contact-form/ ). Let me know if you have any problems.
Attached Files
File Type: zip simple_contact_form.zip (40.2 KB, 57 views)
Last edited by Eric; 04-18-2010 at 01:25 PM.
Eric is offline   Reply With Quote
Old 05-31-2006, 06:40 AM   #2 (permalink)
NamePros Regular
 
unknownz's Avatar
Join Date: Aug 2005
Posts: 727
unknownz is just really niceunknownz is just really niceunknownz is just really niceunknownz is just really niceunknownz is just really niceunknownz is just really niceunknownz is just really niceunknownz is just really nice
 



Thansk for making this one, i was using your previous one on a couple of my sites, i will update them right now!

Thanks
__________________
:laugh:...::::Pakisp.net::::...-The Entertainment Pack Pakisp.net :wave:
Free Web Directory
unknownz is offline   Reply With Quote
Old 06-01-2006, 03:47 PM THREAD STARTER               #3 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
Cool, and no problem I may expand on it further sometime.
Eric is offline   Reply With Quote
Old 06-01-2006, 10:25 PM   #4 (permalink)
NamePros Member
Join Date: May 2006
Posts: 187
ThaiN is an unknown quantity at this point
 



blah its for vbulletin right? i did it on phpBB hahah but errors
ThaiN is offline   Reply With Quote
Old 06-01-2006, 10:45 PM THREAD STARTER               #5 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
Nope...what makes you say that?
Eric is offline   Reply With Quote
Old 06-02-2006, 07:31 AM   #6 (permalink)
BlahBlahBlah...
 
navjotjsingh's Avatar
Join Date: Oct 2005
Location: India
Posts: 1,947
navjotjsingh has much to be proud ofnavjotjsingh has much to be proud ofnavjotjsingh has much to be proud ofnavjotjsingh has much to be proud ofnavjotjsingh has much to be proud ofnavjotjsingh has much to be proud ofnavjotjsingh has much to be proud ofnavjotjsingh has much to be proud of
 



Marrow Donor Program
There should also be a option for custom subject line...like subject to be input from the user. It would be more useful in that way. And regarding that if one forgets from where did the message came..we can use the text message from sitename in the message text itself.

So it provides user of adding his own subject line also.
navjotjsingh is offline   Reply With Quote
Old 06-03-2006, 01:48 PM   #7 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
Join Date: Jan 2005
Location: UK
Posts: 2,408
PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice
 



Originally Posted by SecondVersion
PHP Code:
if (!defined('IN_SC'))
????: NamePros.com http://www.namepros.com/showthread.php?t=202512
{
    die();

Lovely! Thanks a lot!

No, joking aside, its a very comprehensive and well written script. A little OTT in some places maybe, but I will definitely steal some bits from it for my own contact form if I may!
PoorDoggie is offline   Reply With Quote
Old 06-03-2006, 02:34 PM   #8 (permalink)
NamePros Regular
 
Tree's Avatar
Join Date: Feb 2006
Location: Atlanta, GA, USA
Posts: 335
Tree will become famous soon enoughTree will become famous soon enough
 



I always take parts of SV's code. But whenever I do, I put

PHP Code:
//Thanks to Eric Sizemore (SecondVersion) from NamePros.com 
????: NamePros.com http://www.namepros.com/showthread.php?t=202512
Above it. SV is in more site's code than he knows
Tree is offline   Reply With Quote
Old 06-03-2006, 04:37 PM THREAD STARTER               #9 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
Eric is offline   Reply With Quote
Old 06-03-2006, 04:55 PM   #10 (permalink)
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
Join Date: Jan 2005
Location: UK
Posts: 2,408
PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice
 



hmm... for you SV, I will put it in <!-- --> comments! As then any wannabe script kiddie who views my source code will see your legacy!


Tom
PoorDoggie is offline   Reply With Quote
Old 06-06-2006, 09:28 AM   #11 (permalink)
Account Suspended
Join Date: Oct 2005
Location: India
Posts: 633
blackwizard is a jewel in the roughblackwizard is a jewel in the roughblackwizard is a jewel in the rough
 



Thanks for the Script, SecondVersion. I will use it in my new Fan Site after it is completed.
blackwizard is offline   Reply With Quote
Old 09-18-2006, 12:40 AM THREAD STARTER               #12 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
Updated again
Eric is offline   Reply With Quote
Old 09-30-2006, 08:42 AM   #13 (permalink)
Account Suspended
Join Date: Oct 2005
Location: India
Posts: 633
blackwizard is a jewel in the roughblackwizard is a jewel in the roughblackwizard is a jewel in the rough
 



hey SV, Im going to use that for two of my sites.. Thanks a lot man!

Keep Rockin!
blackwizard is offline   Reply With Quote
Old 10-04-2006, 08:24 PM   #14 (permalink)
NamePros Regular
 
Tree's Avatar
Join Date: Feb 2006
Location: Atlanta, GA, USA
Posts: 335
Tree will become famous soon enoughTree will become famous soon enough
 



Random CAPTCHA would be amazing.
Tree is offline   Reply With Quote
Old 10-04-2006, 08:56 PM   #15 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
Join Date: Feb 2006
Posts: 2,796
Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future
 


Autism Autism Autism Autism Autism Autism Autism
audit.php
PHP Code:
<?php
????: NamePros.com http://www.namepros.com/showthread.php?t=202512
 
function audit() {
  
session_start();
  
$digit $_SESSION['digit'];
????: NamePros.com http://www.namepros.com/showthread.php?t=202512
  
$userdigit $_POST['captcha']; 
  
session_destroy();   
  
  if ((
$digit == $userdigit) && ($digit 1)) {
    return 
true;
  } else {
    return 
false;
  }
 
}
?>
button.php
PHP Code:
<?php

$image 
imagecreate(12030);

$white    imagecolorallocate($image0xFF0xFF0xFF);
$gray    imagecolorallocate($image0xC00xC00xC0);
$darkgray imagecolorallocate($image0x500x500x50);

srand((double)microtime()*1000000);

for (
$i 0$i 10$i++) {
    
$x1 rand(0,120);
    
$y1 rand(0,30);
    
$x2 rand(0,120);
    
$y2 rand(0,30);
    
imageline($image$x1$y1$x2$y2 $gray);
}

for (
$i 0$i 5$i++) {
    
$cnum[$i] = rand(0,9);
}


for (
$i 0$i 5$i++) {
    
$fnt rand(3,5);
    
$x $x rand(12 20);
    
$y rand(12); 
    
imagestring($image$fnt$x$y$cnum[$i] , $darkgray); 
}

$digit "$cnum[0]$cnum[1]$cnum[2]$cnum[3]$cnum[4]";

session_start();
$_SESSION['digit'] = $digit;

header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
  
?>
Add this to your form:
Code:
<!-- This isn't setup to match your email script as I don't feel like looking at how you do it right now. -->
<img width="120" height="30" src="button.php" /><br />
<input id="captcha" name="captcha" type="text" value="" /> <label for="captcha">Verification</label>
To test if it's right
PHP Code:
<?php
include('audit.php');
if (
audit()) {
  
// It's right.
} else {
  
// It's wrong.
}
?>
edit: Also, add session_start(); to index.php or the main page. [If it's not there.]
Last edited by Dan; 10-04-2006 at 09:33 PM.
Dan is offline   Reply With Quote
Old 10-05-2006, 04:59 AM THREAD STARTER               #16 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
CAPTCHA added, see first post.
Eric is offline   Reply With Quote
Old 11-26-2006, 11:29 AM   #17 (permalink)
^_^
 
Joey's Avatar
Join Date: May 2005
Location: Maryland
Posts: 976
Joey is a name known to allJoey is a name known to allJoey is a name known to allJoey is a name known to allJoey is a name known to allJoey is a name known to allJoey is a name known to allJoey is a name known to all
 



I'm getting an error. The script is working fine (I'm getting the eMail), but when the form is submitted, I get the following error:

Quote:
Warning: Missing argument 2 for is_spam() in /home/zamblo/public_html/contact/includes/functions.php on line 110
Feel free to test yourself at http://www.zamblo.com/contact_us.php.
????: NamePros.com http://www.namepros.com/showthread.php?t=202512

- Joey
Joey is offline   Reply With Quote
Old 11-26-2006, 11:44 AM   #18 (permalink)
Account Closed
 
B33R's Avatar
Join Date: Mar 2006
Location: UK
Posts: 1,951
B33R has much to be proud ofB33R has much to be proud ofB33R has much to be proud ofB33R has much to be proud ofB33R has much to be proud ofB33R has much to be proud ofB33R has much to be proud ofB33R has much to be proud ofB33R has much to be proud ofB33R has much to be proud of
 

Member of the Month
October 2006
Cancer
Edit functions.php, find this section
Code:
function is_spam($value, $numlinks)
{
    preg_match_all('#(<a href|\[url|http:\/\/)#i', $value, $matches, PREG_PATTERN_ORDER);

    if (count($matches[0]) > SPAM_NUM_LINKS)
    {
        return true;
    }
    return false;
}
and remove this part:
Code:
, $numlinks
Be sure to remove the comma and space before $numlinks too. That should fix it.
B33R is offline   Reply With Quote
Old 11-26-2006, 04:48 PM   #19 (permalink)
^_^
 
Joey's Avatar
Join Date: May 2005
Location: Maryland
Posts: 976
Joey is a name known to allJoey is a name known to allJoey is a name known to allJoey is a name known to allJoey is a name known to allJoey is a name known to allJoey is a name known to allJoey is a name known to all
 



Seems that your solution fixed the problem. Thanks!
Joey is offline   Reply With Quote
Old 12-12-2006, 12:41 PM   #20 (permalink)
BioSpherical.net
 
thepurplecow's Avatar
Join Date: Jun 2006
Location: UK
Posts: 453
thepurplecow is just really nicethepurplecow is just really nicethepurplecow is just really nicethepurplecow is just really nice
 



Thanks, looks good, but I'm having some problems.

See:
http://www.biospherical.net/contact1.html (try sending a message).

It may be a simple problem, I don't know.

Any ideas??
thepurplecow is offline   Reply With Quote
Old 12-12-2006, 12:44 PM   #21 (permalink)
NamePros Expert
 
IAmAllanShore's Avatar
Join Date: Nov 2004
Location: Esse quam videri
Posts: 8,332
IAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond repute
 

Member of the Month
January 2005Member of the Month
February 2007
Ethan Allen Fund Child Abuse Child Abuse Child Abuse Child Abuse Save The Children Save The Children Child Abuse Child Abuse Child Abuse Child Abuse VA Tech Memorial Child Abuse Child Abuse Child Abuse Child Abuse Child Abuse Child Abuse Child Abuse Child Abuse Child Abuse Child Abuse
Note your url location on that one:
http://www.biospherical.net/%3C?php%20echo%20$_SERVER['PHP_SELF'];%20?%3E
I don't know .php , but I know I fixed all my problems with the script by chmod'ing everything correctly...
Best,
-Allan
__________________

Something Witty This Way Comes...
IAmAllanShore is offline   Reply With Quote
Old 12-12-2006, 02:30 PM   #22 (permalink)
Account Closed
 
B33R's Avatar
Join Date: Mar 2006
Location: UK
Posts: 1,951
B33R has much to be proud ofB33R has much to be proud ofB33R has much to be proud ofB33R has much to be proud ofB33R has much to be proud ofB33R has much to be proud ofB33R has much to be proud ofB33R has much to be proud ofB33R has much to be proud ofB33R has much to be proud of
 

Member of the Month
October 2006
Cancer
Try renaming the file to .php rather than .html.

Also remove all this stuff from the top
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>

	<title>BioSpherical | Contact</title>
	<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" />
	<meta name="author" content="TPC - BioSpherical" />
	<meta name="copyright"	content="Copyright 2006 BioSpherical" />	
	<meta name="keywords" content="" />
	<meta name="description" content="" />	
	<meta http-equiv="imagetoolbar" content="no" />

	<link href="bc-stylesheet.css" rel="stylesheet" type="text/css" />
</head>
<html>
<body>
<script>
and also the </script> tag from the bottom. If you want all those head tags in the file, there's already a place in the php file to put it, go to line 51 and you'll see it.
????: NamePros.com http://www.namepros.com/showthread.php?t=202512

In the end, with the head tags you included, your file should look something like this - making sure it's called contact.php rather than .html -
Code:
<?php

/***************************************************************************
*
*   Author   : Eric Sizemore ( www.secondversion.com )
*   Package  : SV's Simple Contact
*   Version  : 1.0.3
*   Copyright: (C) 2005-2006 Eric Sizemore
*   Site     : www.secondversion.com
*   Email    : esizemore05@gmail.com
*   File     : contact.php
*
*   This program is free software; you can redistribute it and/or modify
*   it under the terms of the GNU General Public License as published by
*   the Free Software Foundation; either version 2 of the License, or
*   (at your option) any later version.
*
*   This program is distributed in the hope that it will be useful,
*   but WITHOUT ANY WARRANTY; without even the implied warranty of
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*   GNU General Public License for more details.
*
***************************************************************************/

session_start();

// ####################### Define Important Constants #######################
define('IN_SC', true);

// The email address form submissions will be sent to
define('EMAIL', 'you@example.com');

// Your site/domain name
define('SITE_NAME', 'YourSite.com');

// The subject of the form submissions
define('SUBJECT', 'Message from ' . SITE_NAME);

// This must be numeric, see www.php.net/wordwrap
define('MSG_WORD_WRAP', 75);

// Used for the is_spam function
// The number of links the message must contain to be flagged as spam
define('SPAM_NUM_LINKS', 3);

// ############################### Functions ################################
require_once('includes/functions.php');

// ################################## HTML ##################################
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>

	<title>BioSpherical | Contact</title>
	<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" />
	<meta name="author" content="TPC - BioSpherical" />
	<meta name="copyright"	content="Copyright 2006 BioSpherical" />	
	<meta name="keywords" content="" />
	<meta name="description" content="" />	
	<meta http-equiv="imagetoolbar" content="no" />

	<link href="bc-stylesheet.css" rel="stylesheet" type="text/css" />
</head>

<body>

<h2>Contact</h2>
<p>Please use the following form to contact us. We will respond as soon as possible.</p>
<p>Fields marked by * are required.</p>
<br />
<?php

// ############################ Main Script Start ###########################
if (isset($_POST['submit']) AND $_POST['submit'] != '')
{
    $name = sanitize($_POST['sender_name']);
    $email = sanitize($_POST['sender_email']);
    $message = wordwrap(sanitize($_POST['sender_message'], false), MSG_WORD_WRAP);
    $message = str_replace("\n", '<br>', $message);
    $captcha = sanitize($_POST['captcha']);
    $ip = get_ip();

    if (empty($name) OR empty($email) OR empty($message) OR is_email_injection($name))
    {
        echo 'One or more required fields left blank. Please try again.';
    }
    else if (!is_valid_email($email) OR is_email_injection($email))
    {
        echo 'E-mail is invalid. Please try again.';
    }
    else if (is_spam($message))
    {
        echo 'Sorry, but your message seemed a bit like spam.';
    }
    else if (md5($captcha) != $_SESSION['sc_captcha_code'])
    {
        echo 'The code you entered does not match the code in the image, please try again.';
    }
    else
    {
        $headers = 'From: ' . $name . ' <' . $email . '>' . "\n";
        $headers .= 'Message-ID: <' . md5(uniqid(time())) . '@' . $_SERVER['HTTP_HOST'] . '>' . "\n";
        $headers .= 'MIME-Version: 1.0' . "\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n";
        $headers .= 'Content-transfer-encoding: 8bit' . "\n";
        $headers .= 'Date: ' . date('r', time()) . "\n";
        $headers .= 'X-Priority: 3' . "\n";
        $headers .= 'X-MSMail-Priority: Normal' . "\n";
        $headers .= 'X-Mailer: PHP/' . PHP_VERSION . "\n";
        $headers .= 'X-MimeOLE: Produced By SVs SimpContact v1.0.3' . "\n";

        $send = mail(EMAIL, SUBJECT, "
<html>
<head>
<title>Email from $name</title>
</head>

<body>

<table align=\"center\" cellpadding=\"2\" cellspacing=\"1\">
<tr>
  <td colspan=\"2\">Someone from " . SITE_NAME . " has sent you a message, it is below.</td>
</tr>
<tr>
  <td><b>Sender's name:</b></td>
  <td>$name</td>
</tr>
<tr>
  <td><b>Sender's Email:</b></td>
  <td>$email</td>
</tr>
<tr>
  <td><b>Sender's IP:</b></td>
  <td>$ip</td>
</tr>
<tr>
  <td valign=\"top\"><b>Message:</b></td>
  <td>$message</td>
</tr>
</table>

</body>
</html>
", $headers);

        if ($send)
        {
            echo 'Thank you, ' . $name . ', for contacting us. We will respond asap.';
        }
        else
        {
            echo 'Seems to have been a problem sending the email. Please try again.';
        }
    }
}
else
{
?>
<table cellpadding="2" cellspacing="2">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" style="display: inline;">
<tr>
  <td><strong>Name:*</strong></td>
  <td><input type="text" name="sender_name"></td>
</tr>
<tr>
  <td><strong>E-mail:*</strong></td>
  <td><input type="text" name="sender_email"></td>
</tr>
<tr>
  <td valign="top"><strong>Message:*</strong></td>
  <td><textarea name="sender_message" rows="5" cols="50"></textarea></td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td><img src="captcha.php" border="0" width="252" height="81" alt="CAPTCHA Image" title="CAPTCHA Image"></td>
</tr>
<tr>
  <td><strong>Code:*</strong> (above)</td>
  <td><input type="text" name="captcha" maxlength="5"></td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td><input type="submit" name="submit" value="Submit" style="float: right;"></td>
</tr>
</form>
</table>
<?php
}
?>
<br />
<p>Powered by <a href="http://www.secondversion.com">SVs Simple Contact v1.0.3</a></p>

</body>
</html>
B33R is offline   Reply With Quote
Old 12-12-2006, 03:16 PM   #23 (permalink)
BioSpherical.net
 
thepurplecow's Avatar
Join Date: Jun 2006
Location: UK
Posts: 453
thepurplecow is just really nicethepurplecow is just really nicethepurplecow is just really nicethepurplecow is just really nice
 



Thanks a lot B33R, it seems to work now!! (http://www.biospherical.net/contact.php)

Just to check, there's no way to use the form in a .html file?

Also, off topic, is there any way (using any web language) to use the html of one page in another, but with a simple command?? For example, on line of code takes the html from a specified page??! (I'm probably sounding stupid, but I don't know anything more than basic PHP - HTML and similar languages are the only ones I have a sort-of grasp on!!).
thepurplecow is offline   Reply With Quote
Old 12-12-2006, 03:42 PM   #24 (permalink)
NamePros Expert
 
IAmAllanShore's Avatar
Join Date: Nov 2004
Location: Esse quam videri
Posts: 8,332
IAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond reputeIAmAllanShore has a reputation beyond repute
 

Member of the Month
January 2005Member of the Month
February 2007
Ethan Allen Fund Child Abuse Child Abuse Child Abuse Child Abuse Save The Children Save The Children Child Abuse Child Abuse Child Abuse Child Abuse VA Tech Memorial Child Abuse Child Abuse Child Abuse Child Abuse Child Abuse Child Abuse Child Abuse Child Abuse Child Abuse Child Abuse
iframe the entire thing into a .html file?

That should work, no?

-Allan
__________________

Something Witty This Way Comes...
IAmAllanShore is offline   Reply With Quote
Old 12-13-2006, 10:28 AM   #25 (permalink)
BioSpherical.net
 
thepurplecow's Avatar
Join Date: Jun 2006
Location: UK
Posts: 453
thepurplecow is just really nicethepurplecow is just really nicethepurplecow is just really nicethepurplecow is just really nice
 



Thank you Allan!...don't know why I didn't think of that!!

thepurplecow is offline   Reply With Quote
Reply


LinkBacks (?)
LinkBack to this Thread: http://www.namepros.com/code/202512-simple-contact-form-updated.html
Posted By For Type Date
simple-contact-form - Project Hosting on Google Code This thread Refback 04-20-2010 08:46 AM
My Portfolio - SecondVersion&#039;s Blog This thread Refback 02-05-2010 02:14 PM

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


Liquid Web Smart Servers  
All times are GMT -7. The time now is 10:13 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger