how to validate the minlength and maxlength of textarea? - php

I want to validate the minlength and maxlength of textarea before submitting, can anyone tell me details?
<form id="contact-je" action="<?php echo JURI::current(); ?>" method="post">
<div class="input">
<label id="je_hide_message" for="message"><?php echo JText::_("$message"); ?></label>
<textarea name="je_message" id="message" class="requiredField" rows="4"
placeholder="<?php echo $message; ?>"><?php if (isset($_POST['je_message'])) {
if (function_exists('stripslashes')) {
echo stripslashes($_POST['je_message']);
} else {
echo $_POST['je_message'];
}
} ?></textarea>
<?php if (!isset($_SESSION)) {
if ($messageError != '') { ?><span
class="error"><?php echo $messageError; ?></span><?php }
} ?>
</div>
<div class="input">
<button name="submit" type="submit"
class="je_button"><?php echo JText::_("$submit") ?></button>
<input type="hidden" name="submitted" id="submitted" value="true"/>
</div>
</form>
<?php } ?>
</div>

If you are allowed to use the browser feature, you can just set minlength and maxlength attributes of <textarea>.
<form>
<textarea minlength="5" maxlength="10"></textarea>
<input type="submit">
</form>

I add following codes, but if enter more than 300characters, the form will still be submitted. I don't want to submit if the characters is over 300
// Validate error
$('form#contact-je').submit(function () {
$('form#contact-je .error').remove();
var hasError = false;
$('.requiredField').each(function () {
if ($.trim($(this).val()) == '') {
var labelText = $(this).prev('label').text();
$(this).parent().append('<span class="error">Pls enter ' + labelText + '!</span>');
$(this).addClass('invalid');
hasError = true;
} else if ($(this).hasClass('email')) {
var emailReg = /^([\w-\.]+#([\w-]+\.)+[\w-]{2,4})?$/;
if (!emailReg.test($.trim($(this).val()))) {
var labelText = $(this).prev('label').text();
$(this).parent().append('<span class="error">You\'ve entered an invalid ' + labelText + '!</span>');
$(this).addClass('invalid');
hasError = true;
}
}
});
//Limit message characters
$('#message').keyup(function() {
if ($(this).val().length > 300){
$(this).parent().append('<span class="error">ffffff</span>');
$(this).addClass('invalid');
hasError = true;
}
});
if (!hasError) {
var formInput = $(this).serialize();
$.post($(this).attr('action'), formInput, function (data) {
$('form#contact-je').slideUp("fast", function () {
$(this).before('<span class="success"><strong>Thank you!</strong> We have received your email.<br />We will get back to you in 12 hours.<br />-- Pneuflex China</span>');
});
});
}
return false;
});

Related

Php code to validate and send form data to email

Php code to validate and send form data to an email address
My php wont validate my ajax post call method and have my formdata sent to an email address on submit button click. I am probably missing out some codes and Here is a sample of what my code looks like.
Any answers?
<body>
<div class="tab_content active_tab" id="name">
<form method="post" class="import_form">
<input type="hidden" id="doc_type" name="doc_type" value="" required>
<textarea name="name" placeholder="Name" required></textarea>
<input type="hidden" name="importer1" value="1">
<button type="submit">SEND</button>
</form>
</div>
<div class="tab_content" id="account_type">
<form method="post" class="import_form">
<input type="hidden" id="doc_type" name="doc_type" value="" required>
<textarea name="account_type" placeholder="ACCOUNT TYPE" required></textarea>
<input type="hidden" name="date" placeholder="Date" required>
<input type="hidden" name="importer2" value="1">
<button type="submit">SEND</button>
</form>
</div>
</div>
</div>
<script src="assets/js/jquery.min.html"></script>
<script src="assets/bootstrap/js/bootstrap.min.html"></script>
</body>
<script>
var root_link = "index.html";
forms = document.getElementsByClassName('import_form');
for(let i = 0;i < forms.length; i++){
forms[i].addEventListener('submit',function(e){
e.preventDefault();
data = new FormData(this);
request = new XMLHttpRequest();
request.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
//alert(this.responseText);
if(this.responseText == true){
location = 'image.html';
}
}
};
}
function open_tap(tab){
var tabs = document.getElementsByClassName('tab_content');
var tabs_key = document.getElementsByClassName('import_tab');
for(let i = 0; i < tabs.length; i++){
tabs[i].style.display = 'none';
}
for(let i = 0; i < tabs_key.length; i++){
tabs_key[i].style.borderBottom = 'none';
}
document.getElementById(tab).style.display = 'block';
document.getElementsByClassName(tab)[0].style.borderBottom = '1px solid #fff';
}
</script>
<script>
$("#loader").hide();
function loading(t){
$("#loader").show();
setTimeout(function(){
$("#loader").hide();
},t);
}
$('#name').submit(function(e){
e.preventDefault();
var a = $('#name_val').val(),
b = $('#doc_type').val();
$.ajax({
method:"POST",
url:"set.php",
data:{name:a,doc_type:b,importer1:true},
beforeSend:function(){
loading(2500);
},
success:function(r){
loading(5000);
// alert(r);
location = 'image-2.html';
}
});
});
$('#accountype_form').submit(function(e){
e.preventDefault();
var a = $('#accountype_val').val(),
b = $('#doc_type').val(), c = $('#date').val();
$.ajax({
method:"POST",
url:"set.php",
data:{accounttype_val:a,doc_type:b,date:c,importer2:true},
beforeSend:function(){
loading(2500);
},
success:function(r){
loading(5000);
location = 'image-2.html';
}
});
});
</script>
<?php
if(isset($_POST['submit'])){
$to = "anything#domain.com";
$name = $_POST['name'];
$acounttype = $_POST['accounttype'];
$errorMSG = "";
if (empty($_POST["name"])) {
$errorMSG = "location:'image2_html'";
} else {
$name = $_POST["name"];
}
if (empty($_POST["accounttype"])) {
$errorMSG .= "location:'image2_html'";
} else {
$accounttype = $_POST["accounttype"];
}
?>

How do i stop the form validation code from repeating when i click the submit button (php ajax jquery html)

Hey all i'm new to working with ajax but i am trying to make some form validation and its going well except for this code repeating itself.
This is what happens after clicking the submit button twice... and if i keep pressing submit it keeps repeating. I only need it to show once no matter how many times the submit button is pressed.
Much appreciated to anyone who could give me a hint on how to stop this code repeating!! Thanks!
The forms action calls this php file:
$errors = [];
$data = [];
// change the $error message for each field here
if (empty($_POST['name'])) {
$errors['name'] = '<div class="my-3 alert alert-danger";>Please enter a valid name.</div>';
} else if (!empty($_POST['name'])) {
$errors['name'] = '<div class="my-3 alert alert-success";>Name Entered.</div>';
}
if (empty($_POST['email'])) {
$errors['email'] = '<p class="my-3 alert alert-danger";>Please enter a valid email address.</p>';
} else if (!empty($_POST['email'])) {
$errors['email'] = '';
}
if (empty($_POST['comment'])) {
$errors['comment'] = '<p class="my-3 alert alert-danger";>Please leave a comment.</p>';
} else if (!empty($_POST['comment'])) {
$errors['comment'] = '';
}
// if the fields are not empty then return successful
if (!empty($errors)) {
$data['success'] = false;
$data['errors'] = $errors;
} else {
$data['success'] = true;
$data['message'] = 'Your Request Has Been Successful! <a class="text-success" href="./">Click here to continue.</a>';
}
echo json_encode($data);
I also have this form.js file linked:
$(document).ready(function () {
$("form").submit(function (event) {
var formData = {
name: $("#name").val(),
email: $("#email").val(),
comment: $("#comment").val(),
};
$.ajax({
type: "POST",
url: "./php/process.php",
data: formData,
dataType: "json",
encode: true,
})
.done(function (data) {
console.log(data);
if (!data.success) {
if (data.errors.name) {
$("#name-group").addClass("has-error");
$("#name-group").append(
'<div class="help-block">' + data.errors.name + "</div>"
);
}
if (data.errors.email) {
$("#email-group").addClass("has-error");
$("#email-group").append(
'<div class="help-block">' + data.errors.email + "</div>"
);
}
if (data.errors.comment) {
$("#comment-group").addClass("has-error");
$("#comment-group").append(
'<div class="help-block">' + data.errors.comment + "</div>"
);
}
} else {
$("form").html(
'<div class="alert alert-success">' + data.message + "</div>"
);
}
})
.fail(function (data) {
$("form").html(
'<div class="alert alert-danger">Could not reach server, please try again <a href="./test-form" >here</a>.</div>'
);
});
event.preventDefault();
});
});
And finally the form itself:
<form action="./php/process.php" method="POST">
<div id="name-group" class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Full Name"
onchange="myFunction()" />
</div>
<div id="email-group" class="form-group">
<label for="email">Email</label>
<input type="email" class="form-control" id="email" name="email"
placeholder="email#example.com" onchange="myFunction()" />
</div>
<div id="comment-group" class="form-group">
<label for="comment">Leave a comment:</label>
<input type="text" class="form-control" id="comment" name="comment"
placeholder="Leave a comment" onchange="myFunction()" />
</div>
<button type="submit" class="btn btn-success">
Submit
</button>
</form>

stop form from submitting (tried e.preventDefault() after $.post but it stops form from submitting

I have this in javascript
$('#submit').on('click', function(e) {
$('#message_line').text("");
if(validate_fields_on_submit()) {
e.preventDefault();
return;
}
// e.preventDefault();
var params = $('form').serialize();
$.post('check_duplicate.php', params, function(responseText) {
submitHandler(responseText);
});
// e.preventDefault();
//return false;
});
function submitHandler(response) {
$('#message_line').text("");
response = $.trim(response);
if(response == "" && response.indexOf("<") <= -1)
$('#registration').submit();
else if(response.indexOf("<") == 0) {
var name = $('[name="regusername"]').val();
$('#message_line').text("Some error occured, please try after some time.");
$("#message_line").attr("tabindex",-1).focus();
return false;
} else {
var name = $('[name="regusername"]').val();
var arr = response.split(',');
arr.pop();
arr.toString();
$('#message_line').text("'" + name + "' already exists, Please try different username");
$("#regusername").focus();
return false;
}
$('#busy_wait').css('display','none');
}
HTML CODE
<?php
session_start();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
include("db/helper_functions.php");
if(validate_fields()) {
if(!check_duplicate($_POST["regusername"])) {
$count = insert_record($_POST["fname"],$_POST["lname"],$_POST["email"],$_POST["regusername"],$_POST["regpassword"]);
if($count > 0) {
include("includes/confirmation.php");
exit();
}
else {
$error = "Sorry registration failed, please try again.";
}
}
else {
$error = "Username already exists, please try different username.";
}
}
}
$page_title = "Registration";
if(isset($_SESSION["username"]))
include('includes/header_authorized.html');
else
include('includes/header.html');
?>
<div class="container">
<div class="regform">
<form name="registration" id="registration" method="post" action="registration.php">
<p><span class="req">* required field.</span></p>
<ul>
<li><label for="fname">First Name:</label>
<input type="text" class="textboxborder" id="fname" name="fname" size="20" maxlength="25" autofocus="autofocus" value="<?php if(isset($_POST['fname'])) echo $_POST['fname'];?>"/>
<span class="error" id="errfname">*<?php if(isset($errfname)) echo $errfname;?></span>
</li>
<li><label for="lname">Last Name:</label>
<input type="text" class="textboxborder" id="lname" name="lname" size="20" maxlength="25" value="<?php if(isset($_POST['lname'])) echo $_POST['lname'];?>"/>
<span class="error" id ="errlname">*<?php if(isset($errlname)) echo $errlname;?></span>
</li>
<li><label for="email">Email:</label>
<input type="text" class="textboxborder" name="email" id="email" size="40" maxlength="50" placeholder="abc#xyz.com" value="<?php if(isset($_POST['email'])) echo $_POST['email'];?>"/>
<span class="error" id="erremail">*<?php if(isset($erremail)) echo $erremail;?></span>
</li>
<li><label for="regusername">Username:</label>
<input type="text" name="regusername" id="regusername" size="20" maxlength="30" value="<?php if(isset($_POST['regusername'])) echo $_POST['regusername'];?>"/>
<span class="error" id="errregusername">*<?php if(isset($errregusername)) echo $errregusername;?></span>
</li>
<li><label for="regpassword">Password:</label>
<input type="password" name="regpassword" id="regpassword" size="20" maxlength="15" value="<?php if(isset($_POST['regpassword'])) echo $_POST['regpassword'];?>"/>
<span class="error" id="errregpassword">*<?php if(isset($errregpassword)) echo $errregpassword;?></span>
</li>
<li><label for="regconpassword">Confirm Password:</label>
<input type="password" name="regconpassword" id="regconpassword" size="20" maxlength="15"/>
<span class="error" id="errregconpassword">*<?php if(isset($errregconpassword)) echo $errregconpassword;?></span>
</li>
</ul>
<div id="message_line"> <?php if(isset($error)) echo $error;?></div>
<div class="buttons">
<input type="reset" value="Reset" id="reset"/>
<input type="submit" value="Submit" />
</div>
</form>
<img src="images/loading.gif" id="busy_wait" alt="busy wait icon" />
</div>
</div>
</body>
</html>
If in submit handler control goes in else if or else block form submission does not stop,I tried return false; and I tried using e.preventDefault(); at different places before ajax call and after but that stops form submission even after validation success and successful return from check_duplicate.php
Any help would be appreciated.
Assuming you have a submit button with id=submit, I would
rename the button since calling anything submit is poor practice since you need to actually submit the form programatically.
move the handler to the form submit event - I personally NEVER attach a handler to a submit button
I assume you do NOT want to submit if the validation returns false
Like this
$('#registration').on('submit', function(e) {
e.preventDefault();
$('#message_line').text("");
if(!validate_fields_on_submit()) { // I assume you meant NOT
return;
}
var params = $(this).serialize();
$.post('check_duplicate.php', params, function(responseText) {
submitHandler(responseText);
});
});
the post can be written
$.post('check_duplicate.php', params, submitHandler);
UPDATE Here is the complete script - NOTE IMPERATIVE to rename anything name=submit or id=submit to something else
$(function() {
$('#registration').on('submit', function(e) {
e.preventDefault();
$('#message_line').text("");
if(!validate_fields_on_submit()) { // I assume you meant NOT
return;
}
$('#busy_wait').show();
$.post('check_duplicate.php', $(this).serialize(), function(response) {
response = $.trim(response);
if (response == "" && response.indexOf("<") <= -1) {
$('#registration').submit(); // actually submit the form
}
else if(response.indexOf("<") == 0) {
var name = $('[name="regusername"]').val();
$('#message_line').text("Some error occured, please try after some time.");
$("#message_line").attr("tabindex",-1).focus();
} else {
var name = $('[name="regusername"]').val();
$('#message_line').text("'" + name + "' already exists, Please try different username");
$("#regusername").focus();
}
$('#busy_wait').hide();
});
});
Update3:
$(function() {
$('#registration').on('submit', function(e) {
e.preventDefault();
$('#message_line').text("");
if(!validate_fields_on_submit()) { // I assume you meant NOT
return;
}
$('#busy_wait').show();
var $thisForm=$(this); // save for later
var params = $thisForm.serialize();
$.post('check_duplicate.php', params, function(response) {
response = $.trim(response);
if (response == "" && response.indexOf("<") <= -1) {
// actually submit the form
$.post($thisForm.prop("action"), params, function(response) {
if (response.indexOf("success") !=-1) {
$('#message_line').text(response);
}
else {
$('#message_line').text("something went wrong");
}
$('#busy_wait').hide();
});
}
else if(response.indexOf("<") == 0) {
var name = $('[name="regusername"]').val();
$('#message_line').text("Some error occured, please try after some time.");
$("#message_line").attr("tabindex",-1).focus();
} else {
var name = $('[name="regusername"]').val();
$('#message_line').text("'" + name + "' already exists, Please try different username");
$("#regusername").focus();
}
$('#busy_wait').hide();
});
});
To prevent form submission the best method will be to return false on the onclick client event
Eg
$('#submit').click(function(){
return false;
})

php form action and jquery validation executing at once

My jquery validation and php form are both executing at once, means the validations errors are showing and also the php action is executed. here is the complete code. The jquery form submit function is returning false if the there are errors in form but even thought the form getting executed..
<form class="form-3 form-horizontal ajxfrm " id="step-three" enctype="multipart/form-data" action="<?php echo $html->addLink(array('controller'=>'homes','action'=>'step_three')); ?>" method="post" target="_parent">
<div id="calendar">
<div class="clear"></div>
<div class="control-group">
<div class="control-label">Name<span>*</span></div>
<div class="controls"><input type="text" name="name" id="name" />
<span id="nameInfo"></span></div>
</div>
<div class="control-group">
<div class="control-label">Email<span>*</span></div>
<div class="controls"><input type="text" name="email" id="email" />
<span id="emailInfo"></span></div>
</div>
<div class="control-group">
<div class="control-label">Contact<span>*</span></div>
<div class="controls"><input type="text" name="contact" id="contact" />
<span id="contactInfo"></span></div>
</div>
<div class="control-group">
<div class="control-label">Skype Id<span>*</span></div>
<div class="controls"><input type="text" name="skypeid" id="skype" />
<span id="skypeInfo"></span></div>
</div>
<div style="position:relative">
<div class="control-group">
<div class="control-label">Files<br/><span style="font-size:10px; font-style:italic">(Optional)</span></div>
<div class="controls">
<input id="fileupload" type="file" name="fileupload[]" multiple/>
<span id="fileInfo"></span><br/>
</div>
</div>
</div>
<div class="control-group">
<div class="control-label">Your Message<span>*</span></div>
<div class="controls"><textarea rows="3" name="message" id="message"></textarea>
<span id="messageInfo"></span></div>
</div>
<div class="clear"></div>
</div>
<div id="submit" style=" text-align:right;">
<input type="hidden" name="post" value="1"/>
<input type="submit" class="btn green" value="Next" id="step3submit" style="margin-right:-20%; margin-top:5%"/>
</div>
</form>
Here is the jquery file
$(document).ready(function () {
//global vars
var form = $("#step-three");
var name = $("#name");
var nameInfo = $("#nameInfo");
var email = $("#email");
var emailInfo = $("#emailInfo");
var contact = $("#contact");
var contactInfo = $("#contactInfo");
var skype = $("#skype");
var skypeInfo = $("#skypeInfo");
var message = $("#message");
//On blur
name.blur(validateName);
email.blur(validateEmail);
contact.blur(validateContact);
skype.blur(validateSkype);
message.blur(validateMessage);
//On key press
name.keyup(validateName);
email.keyup(validateEmail);
contact.keyup(validateContact);
skype.keyup(validateSkype);
message.keyup(validateMessage);
//On Submitting
form.submit(function () {
if (validateName() & validateEmail() & validateContact() & validateSkype() & validateMessage())
return true;
else
return false;
});
//validation functions
function validateEmail() {
//testing regular expression
var a = $("#email").val();
var filter = /^\w+#[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/;
//if it's valid email
if (email.val().length == 0) {
email.addClass("error");
emailInfo.text("Required");
emailInfo.addClass("error");
return false;
} else if (filter.test(a)) {
email.removeClass("error");
emailInfo.text("");
emailInfo.removeClass("error");
return true;
}
//if it's NOT valid
else if (!filter.test(a)) {
email.addClass("error");
emailInfo.text("Valid Email Please");
emailInfo.addClass("error");
return false;
}
}
function validateName() {
//if it's NOT valid
if (name.val().length == 0) {
name.addClass("error");
nameInfo.text("Required");
nameInfo.addClass("error");
return false;
}
//if it's valid
else {
name.removeClass("error");
nameInfo.text("");
nameInfo.removeClass("error");
return true;
}
}
function validateContact() {
//if it's NOT valid
if (contact.val().length == 0) {
contact.addClass("error");
contactInfo.text("Required");
contactInfo.addClass("error");
return false;
}
//if it's valid
else {
contact.removeClass("error");
contactInfo.text("");
contactInfo.removeClass("error");
return true;
}
}
function validateSkype() {
//if it's NOT valid
if (skype.val().length == 0) {
skype.addClass("error");
skypeInfo.text("Required");
skypeInfo.addClass("error");
return false;
}
//if it's valid
else {
skype.removeClass("error");
skypeInfo.text("");
skypeInfo.removeClass("error");
return true;
}
}
/* function validatePass1(){
var a = $("#password1");
var b = $("#password2");
//it's NOT valid
if(pass1.val().length <5){
pass1.addClass("error");
pass1Info.text("Ey! Remember: At least 5 characters: letters, numbers and '_'");
pass1Info.addClass("error");
return false;
}
//it's valid
else{
pass1.removeClass("error");
pass1Info.text("At least 5 characters: letters, numbers and '_'");
pass1Info.removeClass("error");
validatePass2();
return true;
}
}
function validatePass2(){
var a = $("#password1");
var b = $("#password2");
//are NOT valid
if( pass1.val() != pass2.val() ){
pass2.addClass("error");
pass2Info.text("Passwords doesn't match!");
pass2Info.addClass("error");
return false;
}
//are valid
else{
pass2.removeClass("error");
pass2Info.text("Confirm password");
pass2Info.removeClass("error");
return true;
}
}*/
function validateMessage() {
//it's NOT valid
if (message.val().length < 10) {
message.addClass("error");
messageInfo.text("More than 10 Characters required");
messageInfo.addClass("error");
return false;
}
if (message.val().length == 0) {
message.addClass("error");
messageInfo.text("Required");
messageInfo.addClass("error");
return false;
}
//it's valid
else {
message.removeClass("error");
messageInfo.text("");
messageInfo.removeClass("error");
return true;
}
}
});
You have to use preventDefault() function. The submit function can't be 'canceled' with returning false. it is an event and there are many handlers 'listening' to it. You have to stop the event from propagating, thus preventing the handlers to handle the event ;)
The code:
$("form").submit(function(e){
if(!(validateName() && validateEmail() && validateContact() && validateSkype() && validateMessage())){
e.preventDefault();
// and maybe some alert() with fail info
}
else{
//whatever you need if validation suceeds
}
});
use && place of &
I hope it will help

Form emailing with script

I'm french (sorry for the english) and I'm looking for a solution to this problem.
I made a form witch send a mail to the adress I indicate in the contact.php file.
The problem is that the mail I receive does not contain the "emailSchool" variable.
Here are some of my files :
My html file :
<div id="formulaire">
<form id="myForm" action="contact.php" method="post">
<label for="emailName">Nom et prénom:</label>
<input name="emailName" type="text" id="emailName"/>
<label for="emailFrom">Email:</label>
<input name="emailFrom" type="text" id="emailFrom"/>
<label for="emailSchool">Ecole :</label>
<input name="emailSchool" type="text" id="emailSchool"/>
<label for="emailMessage">Message: (optionnel)</label>
<textarea name="emailMessage" cols="30" rows="9" id="emailMessage"></textarea>
<input style="padding-left:5px; width:80px; height:32px;" type="image" src="images/send.png" id="submit" class="submit" alt="ENVOYER"/>
<input type="hidden" name="submitted" id="submitted" value="true" />
</form>
My script :
$("#submit").click(function(){
var hasError = false;
var emailReg = /^([\w-\.]+#([\w-]+\.)+[\w-]{2,4})?$/;
var emailFromVal = $("#emailFrom").val();
if(emailFromVal == '') {
$("#emailFrom").addClass("error");
hasError = true;
} else if(!emailReg.test(emailFromVal)) {
$("#emailFrom").addClass("error");
hasError = true;
}
else
{
$("#emailFrom").removeClass("error");
}
var nameVal = $("#emailName").val();
if(nameVal == '') {
$("#emailName").addClass("error");
hasError = true;
}
else
{
$("#emailName").removeClass("error");
}
var schoolVal = $("#emailSchool").val();
if(schoolVal == '') {
$("#emailSchool").addClass("error");
hasError = true;
}
else
{
$("#emailSchool").removeClass("error");
}
var messageVal = $("#emailMessage").val();
if(messageVal == '') {
$("#emailMessage").addClass("error");
hasError = true;
}
else
{
$("#emailMessage").removeClass("error");
}
if(hasError == false) {
$(this).hide();
$("#myForm").fadeOut("fast", function(){
$("#myForm").before('<img src="images/loading.gif" alt="Loading" id="loadingImage" />');
$.post("contact.php", { emailFrom: emailFromVal, emailName: nameVal, emailSchool: schoolVal, emailMessage: messageVal },
function(data){
$("#loadingImage").fadeOut("fast", function() {
$("#loadingImage").before('<p>Votre inscription a bien été pris en compte, nous vous enverrons un email pour confirmer !</p>');
});
}
);
});
}
return false;
}
And my .php file :
<?php
$nameVal=$POST['emailName'];
$emailFromVal=$POST['emailFrom'];
$messageVal=$POST['emailMessage'];
$schoolVal=$POST['emailSchool'];
$to='mymail#gmail.com';
$sujet='Nouvel incrit JEIC CHALLENGE !'.$emailFrom;
$msg='Message :'.$emailMessage;
$mailHeader = "From = {$emailFrom}";
$mailBody = "Nom = {$emailName} Ecole = {$emailSchool}";
mail($to, $sujet, $msg, $mailBody , $mailHeader);
?>
The problem is that I don't have the "School" field in the mail I receive.
Maybe somebody have a solution ?
Thanks a lot.
You are defining:
$schoolVal=$POST['emailSchool'];
And using in your header:
$emailSchool
Maybe change {$emailSchool} into {$schoolVal} ....
You mix POST names and locals...

Categories