Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 316
0 Users 4 Guests Online

Cool PHP Contact Us!

Here you will make a simple but effective PHP Contact Us!

Here Is The Script With Explanation

Add this to your config.php
Code

function cleanvars($content){ //declare the cleanvars function
$content = mysql_real_escape_string($content);
$content = strip_tags($content); //strip html code
$content = addslashes($content); //addslashes to protect from possible SQL Injection
return $content; //return new content
} //end function


PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php 
echo 'Contact Us'//Title Goes Here
if(isset($_POST['contact'])) //if the form is posted
{
$name cleanvars($_POST['name']); //These Check to see if the posts from the form are empty
$email cleanvars($_POST['email']);
$subject cleanvars($_POST['subject']);
$message cleanvars($_POST['message']);
 if(!isset(
$name))
 {
 echo 
'Please enter your name'//if there is no name in the form it displays the message
 
}
 elseif(!isset(
$email))
 {
 echo 
'Please enter your email'//if there is no email in the form in the form it displays the message
 
}
 elseif(!isset(
$subject))
 { 
 echo 
'Please enter the subject'//if there is no subject in the form in the form it displays the message
 
}
 elseif(!isset(
$message))
 {
 echo 
'Please enter your message'//if there is no message in the form in the form it displays the message
 
}
 elseif(
$code $_SESSION['key'])
 { } else {
 
mail('YOUR EMAIL GOES HERE'$subject$message'FROM:'.$email); //the email that it will be sent to goes here, this also sends the email
 
echo 'Mail sent'//This Message Shows Once The Message Is Sent Sucessfully.
 
}
}
else
{
echo 
'
<center>
<form method="post">
<table width="80%" border="0">
<tr>
<td width="30%"><b>Your Name</b></td>
<td width="70%"><input type="text" id="text_edit" name="name" /></td>
</tr>
<tr>
<td width="30%"><b>Your Email</b></td>
<td width="70%"><input type="text" id="text_edit" name="email" /></td>
</tr>
<tr>
<td width="30%"><b>Subject</b></td>
<td width="70%"><input type="text" id="text_edit" name="subject" /></td>
</tr>
<tr>
<td width="30%"><b>Message</b></td>
<td width="70%"><textarea id="text_edit" name="message"></textarea></td>
</tr>
<tr>
<td width="30%"></td>
<td width="70%"><input type="submit" name="contact" id="text_edit" value="Contact Us" /></td>
</tr>
</table>
</form>
</center>'
//This Is A Simple PHP HTML Form, No Need For Explaining If You Need Explaining Just Send Me A Message

}
echo 
'</div>';
?>

If You Need Help Just Ask!
Liquidsteel
Views:
3037
Rating:
Posted on Sunday 4th May 2008 at 12:50 PM
ShadowMage
ShadowMage
Added a different cleanvars function then what he probably has but hey, it should work =)
Posted on Sunday 2nd December 2007 at 05:04 PM
cyruswu
cyruswu
Remove cleanvars who needs cleanvars.

It's not eve na defined function. Get rid of it.
Posted on Friday 16th November 2007 at 03:47 AM
-=InSaNe=-
-=InSaNe=-
Allready put that in. I dont have a free host, dont worry.
Posted on Thursday 15th November 2007 at 07:59 PM
darklight19
darklight19
You may also want to log IP's too.
Posted on Thursday 15th November 2007 at 07:58 PM
darklight19
darklight19
without bot verification someone can spam you and use your email send limit. Most free host are set to about 400-500 emails. If you go above that you can get a fine, or get shut down. 110mb.com is this way, I think they fine you $2,000. So make sure you use bot verification before using this. If you don't know how to do that look at this tutorial (http://www.visualbuilder.com/viewpages.php?art_id=1286&pageorder=1)
Posted on Wednesday 14th November 2007 at 08:13 PM
ShadowMage
ShadowMage
You will need to add bot verification so you dont get spammed. xD
Posted on Wednesday 14th November 2007 at 05:47 PM
DanielXP
DanielXP
It works for Liquidstell because he has the cleanvars() function.

You could add it your self or remove the cleanvars(.....)

Liquidsteel: Send a email with the cleanvars function to us. Subject: "TM265"
Posted on Wednesday 14th November 2007 at 03:16 PM
-=InSaNe=-
-=InSaNe=-
To lazy to fix it. Still does not work :S
Posted on Wednesday 14th November 2007 at 03:33 AM
Liquidsteel
Liquidsteel
:S it works for me. :P
Posted on Wednesday 14th November 2007 at 12:31 AM
-=InSaNe=-
-=InSaNe=-
Fatal error: Call to undefined function cleanvars() in /home/wehabbon/public_html/mehleclan/TheTestPage.php on line 5

To lazy to figure out error :D I will look into it lator.