Hello everyone, i know this might be alot to ask but am having a lot of problem writing the php code to process this form. I got two questions, What type of coding will have to be done for the process.php file? Do i need to ad another .php file i am a newbie and just getting the hang of this.
This what i have so far. Please let me know what code i need to insert into the process.php Thanks in advance.
HTML Form
<form id="contact" action="process.php" method="post">
<fieldset>
<label for="name" id="name_label">Name</label>
<input type="text" name="name" id="name" size="30" value="" class="text-input" />
<span class="error" id="name_error">Please enter name !</span>
<label for="email" id="email_label">Email</label>
<input type="text" name="email" id="email" size="30" value="" class="text-input" />
<span class="error" id="email_error">Please enter email address !</span>
<span class="error" id="email_error2">Please enter valid email address !</span>
<label for="msg" id="msg_label">Your Message</label>
<textarea cols="25" rows="5" name="msg" id="msg" class="text-input"></textarea>
<span class="error" id="msg_error">Please enter message !</span>
<input type="submit" name="submit" class="button" id="submit_btn" value="Send Message"/>
</fieldset>
</form>
Contact.js
$(function() {
$('.error').hide();
$(".button").click(function() {
// validate and process form
// first hide any error messages
$('.error').hide();
var name = $("input#name").val();
if (name == "") {
$("span#name_error").show();
$("input#name").focus();
return false;
}
var email = $("input#email").val();
if (email == "") {
$("span#email_error").show();
$("input#email").focus();
return false;
}
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
if(!emailReg.test(email)) {
$("span#email_error2").show();
$("input#email").focus();
return false;
}
var msg = $("textarea#msg").val();
if (msg == "") {
$("span#msg_error").show();
$("textarea#msg").focus();
return false;
}
var dataString = 'name='+ name + '&email=' + email + '&msg=' + msg;
//alert (dataString);return false;
$.ajax({
type: "POST",
url: "process.php",
data: dataString,
success: function() {
$('#contact_form').html("<div id='message'></div>");
$('#message').html("Contact Form Submitted!. We will be in touch soon.")
.hide()
.fadeIn(1500, function() {
$('#message');
});
}
});
return false;
});
});
Processor.php
<?php
if ((isset($_POST['name'])) && (strlen(trim($_POST['name'])) > 0)) {
$name = stripslashes(strip_tags($_POST['name']));
} else {$name = 'No name entered';}
if ((isset($_POST['email'])) && (strlen(trim($_POST['email'])) > 0)) {
$email = stripslashes(strip_tags($_POST['email']));
} else {$email = 'No email entered';}
if ((isset($_POST['message'])) && (strlen(trim($_POST['message'])) > 0)) {
$phone = stripslashes(strip_tags($_POST['message']));
} else {$phone = 'No message entered';}
ob_start();
?>
<?
$body = ob_get_contents();
$to = 'kswift41@hotmail.com';
$fromname = "Online Contact";
$mail->Subject = "Inquiry From Contact form submitted";
if(!$mail->Send()) {
$subject = 'Contact form failed';
$content = $body;
mail($recipient, $subject, $content, "From: kswift41@hotmail.com\r\nReply-To: $email\r\nX-Mailer: DT_formmail");
exit;
}
?>
No replies to this topic
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









