/    Sign up×
Community /Pin to ProfileBookmark

JS Forms Conflicting

Hi there. Hopefully someone can help me solve this problem as it is driving me insane.

Here is the link to the site I am building. [URL=”http://www.lewiswarren.co.uk/fairwaykenwood_new/index.php”]http://www.lewiswarren.co.uk/fairwaykenwood_new/index.php[/URL]

The first is the contact form at the bottom of the page and the second is the recruitment form that you can get to by clicking the “become a driver” link.

Basically these 2 forms will both send a message to my email address however the recruitment form is blank and I believe this to be because of a conflicting JS file.

I think this is the case as if I fill out the recruitment form on the “become a driver” section, after clicking submit, the relevant “your email has been sent” message does not appear. Instead it appearsunderneath the contact form as there has been a confliction of JS files and it has tried to submit the contact form as a result.

I have tried so many solutions and cannot seem to get these forms to work independently with their correct “message sent” text.

Any how would be great.

The files to take note off are:

[B][B]contact_me.js[/B] (contact form validation. also activates contact_me.php).
contact_me.php[/B]

[B]recruitment.js[/B] (become a driver validation, also activates recruitment.php).
[B]recruitment.php[/B]

[B]jqBootstrapValidation.js[/B] (not too sure what this does. I believe it is also so some of validation but I do know it is called in the JS files mentioned above and both forms use it).

If someone could have a play around with the above and let me know if they can point me in the right direction that would be great.

Here is also the PHP for both forms.

[B]contact_me.php:[/B]

[code=php]<?php
// Check for empty fields
if(empty($_POST[‘name’]) ||
empty($_POST[’email’]) ||
empty($_POST[‘phone’]) ||
empty($_POST[‘message’]) ||
!filter_var($_POST[’email’],FILTER_VALIDATE_EMAIL))
{
echo “No arguments Provided!”;
return false;
}

$name = $_POST[‘name’];
$email_address = $_POST[’email’];
$phone = $_POST[‘phone’];
$message = $_POST[‘message’];

// Create the email and send the message
$to = ‘[email protected]’; // Add your email address inbetween the ” replacing [email protected] – This is where the form will send a message to.
$email_subject = “Website Contact Form: $name”;
$email_body = “You have received a new message from your website contact form.nn”.”Here are the details:nnName: $namennEmail: $email_addressnnPhone: $phonennMessage:n$message”;
$headers = “From: [email protected]”; // This is the email address the generated message will be from. We recommend using something like [email protected].
$headers .= “Reply-To: $email_address”;
mail($to,$email_subject,$email_body,$headers);
return true;
?>
[/code]

[B]recruitment.php:[/B]

[code=php]<?php
// Check for empty fields
if ( empty($_POST[‘name’]) || empty($_POST[‘phone’]) ) {
echo “No arguments Provided!”;
return false;
}

$name = $_POST[‘name’];
$phone = $_POST[‘phone’];

// Create the email and send the message
$to = ‘[email protected]’; // Add your email address inbetween the ” replacing [email protected] – This is where the form will send a message to.
$email_subject = “Recruitment Enquiry: $name”;
$email_body = “Someone has expressed interest in joining Fairway and Kenwood.nn”.”Here are the details:nnName: $namennPhone: $phone”;
$headers = “From: [email protected]”; // This is the email address the generated message will be from. We recommend using something like [email protected].
$headers .= “Reply-To: [email protected]”;
mail($to,$email_subject,$email_body,$headers);
return true;
?>[/code]

Thanks,

Lewis.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@rootNov 29.2014 — You need to use PHP_EOL for your end of lines, it will automatically insert a rn or n depending on the base operating system.

Here is a tutorial that gives a fully working set of examples for you to manipulate in to something to go... http://webcheatsheet.com/php/send_email_text_html_attachment.php
×

Success!

Help @lewisia 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.19,
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,
)...