/    Sign up×
Community /Pin to ProfileBookmark

HTML5 / PHP mailer function w/ javascript

Hello everyone,
Its a pleasure to be here … This is my first post . .

I’m pretty new in the web developping process. escpecially in Php. here is my question . .
I’ll be quite honest, I have purchased an html5 template for a my website, to my knowledge I have done all modification to it, text, css, scripts, etc . . although, I’m stuck with php in my contact form.
The reason to it is that there is Javascript involved. I have so many online tutorials on how to write a php mailer function, but non of them work and I’ll be honest I’m stuck with it.

So, dont wont someone to write me a code . . although, I’ll be greatful if someone will explain me what and how should I connect all those files in between them.
I will show you what I got . .

[B][SIZE=5]This is my Html Index.html() i will later save it as a .php[/SIZE][/B]

[code]
<form class=”fixed” id=”contact-form” name=”contact-form” method=”post” action=””>

<fieldset>

<div id=”formstatus”></div>

<input class=”span8″ id=”name” type=”text” name=”name” value=”” placeholder=”Your name”>

<input class=”span8″ id=”email” type=”text” name=”email” value=”” placeholder=”email”>

<input class=”span8″ id=”subject” type=”text” name=”subject” value=”” placeholder=”subject”>

<textarea class=”span8″ id=”message” name=”message” rows=”7″ cols=”25″ placeholder=”message”></textarea>

<input id=”submit” type=”submit” name=”submit” value=”submit”>

</fieldset>
</form>
[/code]

[B][SIZE=5]Here is the css for alerts / elements.css()[/SIZE][/B]

[code]
.alert {
padding: 13px 15px;
border: 1px solid #d1d1d1;
border-radius: 3px;
-webkit-box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1);
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1);
margin-bottom: 30px;
background-color: #f8f8f8;
}

.alert i {
position: relative;
top: 1px;
margin-right: 7px;
font-size: 16px;
}

.alert.info {
border: 1px solid #86cde3;
background-color: #cce9f2;
color: #3194b1;
}

.alert.success {
border: 1px solid #b3cda1;
background-color: #d8f1c6;
color: #749958;
}

.alert.error {
border: 1px solid #e1a1a1;
background-color: #f9d9d9;
color: #b55454;
}

.alert.warning {
border: 1px solid #d1c9ae;
background-color: #fbf4dd;
color: #978c68;
}
[/code]

[B][SIZE=5]Here is the layout.css[/SIZE][/B]

[code]
#contact { padding-top: 120px; }

/* Contact Info */

.contact-info {
list-style: none;
margin-bottom: 60px;
}

.contact-info li {
position: relative;
padding-left: 50px;
margin-bottom: 25px;
}

.contact-info li:last-child { margin-bottom: 0; }
.contact-info li a { color: #5f5f5f; }

.contact-info li i {
position: absolute;
top: 0;
left: 0;
display: inline-block;
width: 32px;
margin-right: 20px;
background-color: #252525;
color: #fff;
font-size: 14px;
line-height: 32px;
text-align: center;
}

#contact-form {
overflow: hidden;
margin: 60px 0 70px 0;
}

#contact-form fieldset { }

label.validation-error { color: #b55454; }

input.validation-error,
textarea.validation-error,
select.validation-error { border: 1px solid #a1a1a1; }

#contact-form #formstatus {}

#contact-form input[type=”text”],
#contact-form textarea {
padding: 20px;
border: none;
border-bottom: 1px solid #252525;
color: #5f5f5f;
resize: none;
}

#contact-form input[type=”submit”] {
border: 1px solid #252525;
margin-top: 60px;
background-color: transparent;
color: #252525;
-webkit-transition: all 0.3s;
transition: all 0.3s;
}

#contact-form input[type=”submit”]:hover {
background-color: #252525;
color: #fff;
}
[/code]

[SIZE=5][B]and Here is my java script /script.js[/B][/SIZE]

[code]
function handleContactForm() {

if(typeof $.fn.validate != ‘undefined’){

$(‘#contact-form’).validate({
errorClass: ‘validation-error’, // so that it doesn’t conflict with the error class of alert boxes
rules: {
name: {
required: true
},
email: {
required: true,
email: true
},
subject: {
required: true
},
message: {
required: true
}
},
messages: {
name: {
required: “Field is required!”
},
email: {
required: “Field is required!”,
email: “Please enter a valid email address”
},
subject: {
required: “Field is required!”
},
message: {
required: “Field is required!”
}
},
submitHandler: function(form) {
var result;
$(form).ajaxSubmit({
type: “POST”,
data: $(form).serialize(),
url: “_layout/php/send.php”,
success: function(msg) {

if (msg == ‘OK’) {
result = ‘<div class=”alert success”><i class=”fa fa-check-circle-o”></i>The message has been sent!</div>’;
$(‘#contact-form’).clearForm();
} else {
result = ‘<div class=”alert error”><i class=”fa fa-times-circle”></i>’ + msg + ‘</div>’;
}
$(“#formstatus”).html(result);

},
error: function() {

result = ‘<div class=”alert error”><i class=”fa fa-times-circle”></i>There was an error sending the message!</div>’;
$(“#formstatus”).html(result);

}
});
}
});

}

}
[/code]

I will be super greatfull if someone can help me out . . .

Regards,
Eugene

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@rootJul 18.2014 — Code blocks wrap them in appropriate forum tags please.

[B][[/B][B]CODE[/B][B]][/B] ... [B][[/B][B]/CODE[/B][B]][/B] for anything like JavaScript, CSS and text that relates to your programming.

[B][[/B][B]HTML[/B][B]][/B] ... [B][[/B][B]/HTML[/B][B]][/B] for HTML

[B][[/B][B]PHP[/B][B]][/B] ... [B][[/B][B]/PHP[/B][B]][/B] for PHP

You are more likely to get a response to your query.

*** code tags added ***
Copy linkTweet thisAlerts:
@WyattVWJul 19.2014 — change the value of action in your form tag to the php page you are making and then the mailer is pretty easy, just create a variable for each of the inputs in your form, then its as easy as using the php mail function like this.

you asked us not to write the script for you so here is an example of something i have used
[code=php]
// EDIT THE 3 LINES BELOW AS REQUIRED

$email_to = "[email protected]";

$email_subject = "Subject of Email";

$email_from = "[email protected]";

// a basic if statement to check if your form has been submitted or not
if (isset($_POST['name']) ||

isset($_POST['street']) ||

isset($_POST['city']) {
}



$name = $_POST['name']; // required

$street = $_POST['street']; // required

$city = $_POST['city'];

// create the email message by appending descriptive information around your variables

$email_message .= "Name: ".clean_string($name)."nn";

$email_message .= "Address nn";

$email_message .= "Street: ".clean_string($street)."nn";


// and now the php mailer function

// create email headers

$headers = 'From: '.$email_from."rn".

'Reply-To: '.$email_from."rn" .

'X-Mailer: PHP/' . phpversion();

@mail($email_to, $email_subject, $email_message, $headers);

[/code]
×

Success!

Help @Jokersss007 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...