CONTACT.php
<script type="text/javascript">
//message box validation
function limitarelungime(obj, length){
var lungime=length
if (obj.value.length>lungime)
obj.value=obj.value.substring(0, lungime)
}
//phone number velidation
function numere(e){
var unicode=e.charCode? e.charCode : e.keyCode
if (unicode!=8){
if (unicode<48||unicode>57)
return false
}
}
function limitarelungime(obj, length){
var lungime=length
if (obj.value.length>lungime)
obj.value=obj.value.substring(0, lungime)
}
//email form validation
function everif(str) {
var at="@"
var punct="."
var lat=str.indexOf(at)
var lstr=str.length
var lpunct=str.indexOf(punct)
if (str.indexOf(at)==-1){
alert("Valid email must be entered")
return false
}
if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
alert("Valid email must be entered")
return false
}
if (str.indexOf(punct)==-1 || str.indexOf(punct)==0 || str.indexOf(punct)==lstr){
alert("Valid email must be entered")
return false
}
if (str.indexOf(at,(lat+1))!=-1){
alert("Valid email must be entered")
return false
}
if (str.substring(lat-1,lat)==punct || str.substring(lat+1,lat+2)==punct){
alert("Valid email must be entered")
return false
}
if (str.indexOf(punct,(lat+2))==-1){
alert("Valid email must be entered")
return false
}
if (str.indexOf(" ")!=-1){
alert("Valid email must be entered")
return false
}
return true
}
function evalid(){
var emailID=document.contact_form.mail
if (everif(emailID.value)==false){
emailID.focus()
return false
}
//empty field validation
var fname=document.contact_form.fname
if ((fname.value==null)||(fname.value=="")){
alert("Fields marqued with * must be entered")
fname.focus()
return false
}
var lname=document.contact_form.lname
if ((lname.value==null)||(lname.value=="")){
alert("Fields marqued with * must be entered")
lname.focus()
return false
}
var subject=document.contact_form.subject
if ((subject.value==null)||(subject.value=="")){
alert("Fields marqued with * must be entered")
subject.focus()
return false
}
var message=document.contact_form.message
if ((message.value==null)||(message.value=="")){
alert("Fields marqued with * must be entered")
message.focus()
return false
}
return true
}
</script>
<form name="contact_form" method="post" action="mailer.php" onSubmit="return evalid()">
<table border="0"><tr>
<td>Title</td>
<td colspan="2"><select name="title">
<option selected="selected">Mr</option>
<option>Mrs
</select>
</td>
</tr><tr>
<td>First Name *</td>
<td colspan="2"><input name="fname" type="text" size="30" /></td>
</tr><tr>
<td>Last Name *</td>
<td colspan="2"><input name="lname" type="text" size="30" /></td>
</tr><tr>
<td>Your E-mail *</td>
<td colspan="2"><input type="text" name="mail" size="30" /></td>
</tr><tr>
<td>Address</td>
<td colspan="2"><input name="address" type="text" size="30" /></td>
</tr><tr>
<td>City</td>
<td colspan="2"><input name="city" type="text" size="30" /></td>
</tr><tr>
<td>County</td>
<td colspan="2"><input name="county" type="text" size="30" /></td>
</tr><tr>
<td>Zip Code</td>
<td colspan="2"><input type="text" name="zip" size="10" /></td>
</tr><tr>
<td>Country</td>
<td colspan="2"><input name="country" type="text" size="30" /></td>
</tr><tr>
<td>Phone</td>
<td colspan="2"><input name="phone" type="text" size="30" onkeypress="return numere(event)" onkeyup="return limitarelungime(this, 10)" /></td>
</tr><tr>
<td>Date Of Birth </td>
<td colspan="2"><input type="text" name="d" value="dd" size="2" maxlength="2" /> /
<input type="text" name="m" value="mm" size="2" maxlength="2" /> /
<input type="text" name="y" value="yyyy" size="6" maxlength="4" />
</td>
</tr><tr>
<td>Web Site</td>
<td colspan="2"><input name="web" value="http://" type="text" size="30" /></td>
</tr><tr>
<td>Message Priority </td>
<td colspan="2"><select name="mpriority">
<option selected="selected">Normal</option>
<option>Low</option>
<option>High</option>
<option>Urgent</option>
</select>
</td>
</tr><tr>
<td>Subject *</td>
<td colspan="2"><input name="subject" type="text" size="30" /></td>
</tr><tr>
<td>Message *</td>
<td colspan="2"><textarea name="message" onkeyup="return limitarelungime(this, 255)" cols="35" rows="5"></textarea></td>
</tr><tr>
<td><p>Security Code*<br/>
</p>
</td>
<td><input id="chapcha_code" size="10" name="chapcha_code" type="text" /> </td>
<td><img src="security_image.php" border="0" /></td>
</tr><tr>
<td> </td>
<td colspan="2"> </td>
</tr>
<tr>
<td><input type="reset" name="reset" value="Reset"/></td>
<td align="right"><input type="submit" name="Submit" value="Submit"></td><td align="right"><a href="http://www.scriptgenerator.net/71/HTML%7B47%7DPHP-Contact-Form-Mailer-Generator/" title="Valid Contact Form"><img src="http://www.scriptgenerator.net/images/validform.jpg" alt="Valid Contact Form" width="20" height="20" border="0" /></a></td>
</tr>
</table>
</form>
Mailer.php
?php session_start();
if(isset($_POST['Submit'])) { if( $_SESSION['chapcha_code'] == $_POST['chapcha_code'] && !empty($_SESSION['chapcha_code'] ) ) {
$youremail = '********@gmail.com';
$fromsubject = '*********@yahoo.com';
$title = $_POST['title'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$mail = $_POST['mail'];
$address = $_POST['address'];
$city = $_POST['city'];
$web = $_POST['web'];
$county = $_POST['county'];
$zip = $_POST['zip'];
$country = $_POST['country'];
$phone = $_POST['phone'];
$mpriority = $_POST['mpriority'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$d = $_POST['d'];
$m = $_POST['m'];
$y = $_POST['y'];
$birthdate = $d.'/'.$m.'/'.$y;
$to = $youremail;
$mailsubject = 'Masage recived from'.$fromsubject.' Contact Page';
$body = $fromsubject.'
The person that contacted you is '.$title.' '.$fname.' '.$lname.'
Address: '.$address.'
'.$city.', '.$county.', '.$zip.', '.$country.'
Date of Birth: '.$birthdate.'
Phone Number: '.$phone.'
E-mail: '.$mail.'
Web Site: '.$web.'
Priority: '.$mpriority.'
Subject: '.$subject.'
Message:
'.$message.'
|---------END MESSAGE----------|';
echo "Thank you fo your feedback. I will contact you shortly if needed.<br/>Go to <a href='/index.php'>Home Page</a>";
mail($to, $subject, $body);
unset($_SESSION['chapcha_code']);
} else {
echo 'Sorry, you have provided an invalid security code';
}
} else {
echo "You must write a message. </br> Please go to <a href='/contact.php'>Contact Page</a>";
}
?>
Security image
<?php session_start();
class captcha {
var $font = 5;
function random($nr) {
$letters="23456789bcdfghjkmnpqrstvwxyz";
while ($i < $nr) {
if($i==rand(0,$nr-1)) {
$text .= substr(strtoupper($letters), mt_rand(0, strlen($letters)-1), 1);
}
else
{
$text .= substr($letters, mt_rand(0, strlen($letters)-1), 1);
}
$i++;
}
return $text;
}
function captcha($width,$height,$nru) {
$text=$this->random($nru);
$image = @imagecreate($width, $height) or die('unable create image!');
$bg_col = imagecolorallocate($image, 0, 191, 255);
$txt_col = imagecolorallocate($image, 255, 255, 255);
$rand_col = imagecolorallocate($image, 0, 0, 0);
imagefill($image, 100, 100, $bg_col);
imageantialias($image, true);
imagestring($image, $this->font , rand(1, 10), rand(1,10), $text, $txt_col);
imageline($image, rand(0,$width), rand(0,$height), rand(0,$width), rand(0,$height), $rand_col);
for( $i=0; $i<6; $i++ ) {
imagefilledellipse($image, rand(0,$width), rand(0,$height), 1, 1, $rand_col);
}
header('Content-Type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
$_SESSION['chapcha_code'] = strtolower($text);
}
}
$width='70';
$height='25';
$nru='5';
$iesire = new captcha($width,$height,$nru);
?>
Create your own HTML - PHP contact form in seconds. Our free online contact form generator helps you create HTML - PHP contact forms for your website, with no programming required. By using our easy to use contact form wizard you can design simple or complex contact forms that your users can use it to send you emails. After creating the web form, you get a code to paste in your website. You do not need special skills to insert it in to your web page. Just make shore your webhosting provider suppors PHP. The contact form does NOT require a MySQL database, this means it is simpler and faster to integrate it in to your web page.
You have the option to select your contact form fields and the security options that you need. We also provide you with an optional captcha security code, image verification, that will stop spammers from sending you unwanted or automated submissions.
***Later edit: We reliced the version 2 of our contact form. You can use the new HTML-PHP-jQuery ContactForm v2. or you can see and try the the DEMO contact form here
Please tell us if you
this generator.
contact.php | |
mailer.php | |
security_image.php | |
Title | ||
First Name * | ||
Last Name * | ||
Your E-mail * | ||
Address | ||
City | ||
County | ||
Zip Code | ||
Country | ||
Phone | ||
Date Of Birth | / / | |
Web Site | ||
Message Priority | ||
Subject * | ||
Message * | ||
Security Code* | ||
Niciun comentariu:
Trimiteți un comentariu