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

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
6 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 09-30-2005, 08:15 PM THREAD STARTER               #1 (permalink)
Tech Support
Join Date: Mar 2005
Posts: 4,944
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


I've wrote a simple contact form/script. Email validation etc. Hope you like it.

contact.php
PHP Code:
<?php

/*
SVs SimpContact v1.0.0
Copyright © 2005 SecondVersion
http://www.secondversion.com
*/

echo 'You can use the following form to contact us.
<br>
All fields required.
<br>
<form method="post" action="contact.php">
Name:
<br>
<input type="text" name="name" size="20">
<br>
<br>
E-mail address:
<br>
<input type ="text" name="email" size="20">
<br>
<br>
Subject:
<br>
<input type ="text" name="sub" size="20">
<br>
<br>
Message:
<br>
<textarea rows="5" cols="35" name="message" wrap="virtual"></textarea>
<br>
<input type="submit" name="submit" value="Submit">
<br>
<br>
Powered by: <a target="_blank" href="http://www.secondversion.com">SVs SimpContact v1.0.0</a>.
</form>'
;

if(!empty(
$_POST['submit']))
{

$name $_POST['name'];
$message $_POST['message'];
$email $_POST['email'];
$sub $_POST['sub'];
$ip $_SERVER['REMOTE_ADDR'];

//Check for a valid email..
$validate eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$"$email);
????: NamePros.com http://www.namepros.com/code/127903-simple-contact-form.html

if(!
$validate)
{
echo(
"<br>" $email " is not a valid email.");
}
else
{
$e $email;
}

//Required Fields, you can add or remove fields as neccessary.
//Did they leave them empty?

if(!$name || !$message || !$e)
{
echo 
'<br>One or more required fields were left blank, please enter all required data.';
}
else
{

//Get the date...
$date date("M d Y");

//What email do you want it sent to?
$youremail "you@domain.com";

//What subject to do want the email to be?
$subject "Subject";

//Send the data...
$name stripslashes($name);
????: NamePros.com http://www.namepros.com/showthread.php?t=127903
$subj stripslashes($sub);
$message stripslashes($message);
$msg wordwrap($message70"<br>");

$headers 'From: '.$e.'';
$send mail("$youremail""$subject","

<b>Name:</b> 
$name

<b>E-mail address:</b> 
$e

<b>Subject:</b> 
$subj

<b>Message:</b>
$msg

<b>Message sent on:</b> 
$date
<b>IP:</b> 
$ip

"
$headers);

if(
$send)
{
echo 
'<br>Thanks for contacting us.';
}
else
{
echo 
'<br>Seems to be a problem, please try again later.';
}
}
}
?>

</body>
</html>
Enjoy!

-Eric
Last edited by SecondVersion; 10-06-2005 at 10:33 PM.
Eric is offline  
Old 09-30-2005, 08:20 PM   #2 (permalink)
DNOA Member
Join Date: May 2004
Posts: 5,040
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
 


Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
Nice and helpful, especially for beginners - great thing to learn from! Rep added!
mholt is offline  
Old 09-30-2005, 08:48 PM THREAD STARTER               #3 (permalink)
Tech Support
Join Date: Mar 2005
Posts: 4,944
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
Originally Posted by compuXP
Nice and helpful, especially for beginners - great thing to learn from! Rep added!
Thanks. Yeah, I kept that in mind when writing it, wanted to keep it as simple as possible. And posted it in the hopes a beginner etc would take it learn/build on it. Hope it helps a few.
????: NamePros.com http://www.namepros.com/showthread.php?t=127903


-Eric
Eric is offline  
Old 09-30-2005, 08:55 PM   #4 (permalink)
Senior Member
 
commes's Avatar
Join Date: May 2005
Location: Regina, Sask, Canada
Posts: 1,318
commes is just really nicecommes is just really nicecommes is just really nicecommes is just really nice
 



i might use that when i make an about us page, thats if i ever get around to doing so lol
commes is offline  
Old 09-30-2005, 10:10 PM   #5 (permalink)
Senior Member
 
JoshHendo's Avatar
Join Date: Apr 2005
Location: Australia
Posts: 1,091
JoshHendo is a jewel in the roughJoshHendo is a jewel in the roughJoshHendo is a jewel in the rough
 



Thanks
*sigh* why did i bother to code my own, I should know SV is going to write one *sigh*
__________________
:bingo: :kickass: :lala: :notme: :great: :gn:
JoshHendo is offline  
Old 10-04-2005, 10:22 AM   #6 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes
Great work second
unknowngiver is offline  
Old 10-04-2005, 11:05 AM   #7 (permalink)
Senior Member
Join Date: Mar 2004
Posts: 1,402
primacomputer is a jewel in the roughprimacomputer is a jewel in the roughprimacomputer is a jewel in the rough
 



Your email validation regex has some problems. There are a number of valid mailbox characters you haven't included. In particular the “+” which I've seen quite a few times.

I appreciate that you allow for a host name instead of limiting users to a mailbox and domain name like many broken scripts. However, while technically possible, I doubt you need to allow for hosts with an underscore, and certainly not a percent.
primacomputer is offline  
Closed Thread


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Most dropped (expired) .us's today had THIS in the whois, what does it mean? OvenMitt Domain Newbies 4 07-18-2005 02:36 PM
Paypal Settlement CMachuca The Break Room 3 07-31-2004 10:14 PM
PAYPAL Litigation johnn Domain Name Discussion 6 07-31-2004 09:51 PM
Paypal Settlement Lord The Break Room 2 07-30-2004 09:30 PM
About a domain... axilant Domain Name Discussion 8 05-21-2004 01:34 AM

 
All times are GMT -7. The time now is 02:13 PM.

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