Skip to content

Commit

Permalink
fixed all php and js bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Harmanku committed Jan 18, 2020
1 parent 610d137 commit 2466bd1
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 31 deletions.
4 changes: 2 additions & 2 deletions ContactUs.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ <h3 class="font-weight-bold my-4">Contact Us</h3>
<!-- Prefered Option -->
<select class="browser-default custom-select" id="textok" name="textok">
<option disabled selected>Text Ok?</option>
<option value="1">Yes</option>
<option value="2">No</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions Volunteer.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@
<div class="md-form md-outline mb-0">
<select class="browser-default custom-select select-font" id="textok" name="textok">
<option value="" disabled selected>Text Ok?</option>
<option value="1">Yes</option>
<option value="2">No</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions contactus.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
die();
}

$content="From: $name \n Email: $email \n Message: $message \n Phone: $Phone Texting Ok: $textok" ;
$content="From: $name \n Email: $email \n Phone: $Phone \n Texting Ok: $textok \n Subject: $subject \n Message: $message \n " ;
$recipient = "EmiliosNewsletter@gmail.com";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $content, $mailheader) or die("Error!");
mail($recipient, "Contact Us Form Submission", $content, $mailheader) or die("Error!");
echo "Email sent!";
?>
12 changes: 7 additions & 5 deletions js/ContactValidation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
function ValidateContactUsForm() {

var name = document.getElementById('name').value;
document.getElementById('name').className = "form-control is-valid"
if (name == "") {
Expand All @@ -23,7 +24,7 @@ function ValidateContactUsForm() {
}

var phone = document.getElementById('Phone').value;
console.log(document.getElementById('textok').value);

if (phone !== "") {
document.getElementById('textok').className="browser-default custom-select"
if (document.getElementById('textok').value !== "Text Ok?") {
Expand Down Expand Up @@ -54,9 +55,9 @@ function ValidateContactUsForm() {
'name': $('input[name=name]').val(),
'email': $('input[name=email]').val(),
'subject': $('input[name=subject]').val(),
'message': $('textarea[name=message]').val(),
'Phone':$('input[name=Phone]').val(),
'textok':$('select[name=textok]').val()
'Phone': $('input[name=Phone]').val(),
'textok': $('select[name=textok]').val(),
'message': $('textarea[name=message]').val()
};


Expand All @@ -75,5 +76,6 @@ function ValidateContactUsForm() {
}
});

document.getElementById('contact-us-form').submit();
window.alert("Email has been sent!");
location.reload();
}
34 changes: 20 additions & 14 deletions js/VolunteerValidation.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
function volunteerSubmit() {
var name = document.getElementById('name').value;
document.getElementById('name').className = "form-control is-valid"
if (name == "") {

if (name == "") {
document.getElementById('name').className = "form-control is-invalid"
return false;
}
var email = document.getElementById('email').value;
document.getElementById('email').className = "form-control is-valid"
if (email == "") {

document.getElementById('email').className = "form-control is-invalid"
return false;
} else {
Expand All @@ -20,23 +20,23 @@ function volunteerSubmit() {
return false;
}
}

var phone = document.getElementById('Phone').value;
console.log(document.getElementById('textok').value);
if (phone !== "") {
document.getElementById('textok').className="browser-default custom-select"
document.getElementById('textok').className = "browser-default custom-select"
if (document.getElementById('textok').value !== "") {
document.getElementById('textok').className="browser-default custom-select is-valid"
document.getElementById('textok').className = "browser-default custom-select is-valid"
} else {
document.getElementById('textok').className="browser-default custom-select is-invalid"
document.getElementById('textok').className = "browser-default custom-select is-invalid"
return false;
}
}

var subject = document.getElementById('subject').value;
document.getElementById('subject').className = "form-control is-valid"
if (subject == "") {

document.getElementById('subject').className = "form-control is-invalid"
return false;
}
Expand All @@ -46,32 +46,38 @@ function volunteerSubmit() {
document.getElementById('message').className = "form-control is-invalid"
return false;
}


formData = {
'name': $('input[name=name]').val(),
'email': $('input[name=email]').val(),
'subject': $('input[name=subject]').val(),
'message': $('textarea[name=message]').val(),
'Phone':$('input[name=Phone]').val(),
'textok':$('select[name=textok]').val()
'Phone': $('input[name=Phone]').val(),
'textok': $('select[name=textok]').val()
};


$.ajax({
url: "contactus.php",
url: "volunteer.php",
type: "POST",
data: formData,
success: function (data, textStatus, jqXHR) {

$('#status').text(data.message);
if (data.code) //If mail was sent successfully, reset the form.
$('#volunteerForm').closest('form').find("input[type=text], textarea").val("");

window.alert("Email has been sent!");
location.reload();
},
error: function (jqXHR, textStatus, errorThrown) {
$('#status').text(jqXHR);

window.alert("Email has not been Sent! Reload and try again.")
}
});

document.getElementById('volunteerForm').submit();


}
9 changes: 8 additions & 1 deletion js/newsletter.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,18 @@ function newsletter() {
$('#status').text(data.message);
if (data.code) //If mail was sent successfully, reset the form.
$('#news').closest('form').find("input[type=text], textarea").val("");

window.alert("You have signed up for the newsletter!");
location.reload();
},
error: function (jqXHR, textStatus, errorThrown) {
$('#status').text(jqXHR);
window.alert("Email not sent. Try reloading the Page.")
}
});

document.getElementById('news').submit();




}
20 changes: 17 additions & 3 deletions newsletter.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
<?php
if(isset($_POST['news']))
$news = $_POST['news'];
if(isset($_POST['email']))
$email = $_POST['email'];

$message = "Here are the instructions on how to add someone to the newsletter label. \n
1) Copy the email that was sent with this email. $email \n
2) On the top right of the screen there is a icon of nine cubes. Click on that and click on Contacts. \n
3) Near the top left of the Screen click on Create Contact. A window will pop up. \n
4) Type in or paste in the email you saved from this message. Here it is again. $email \n
5) The contact should pop up in your list of contact. Click on the new contact and drag it over the label called --> Emilio's Newsletter <-- and that should add the contact to the newsletter. \n
\n \n \n \n
If you want to Send an Email to your subscribers \n
1) If you want to send to an email to all subscribers. Go to your G-mail page. Click on the plus sign or the compose button. A new email box should pop up. \n
2) In the To section type the name of the label. --> Emilio's Newsletter <-- and autofill should kick in. Click on the option and you're good to go. Fill out what you want to send and send it.";


$recipient = "EmiliosNewsletter@gmail.com";
mail($recipient, "New Newsletter Subscriber", "Test Test") or die("Error!");
$mailheader = "From: $email \r\n";
mail($recipient, "New Newsletter Subscriber", $message, $mailheader) or die("Error!");
echo "Email sent!";

?>
4 changes: 2 additions & 2 deletions volunteer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
die();
}

$content="From: $name \n Email: $email \n Message: $message \n Phone: $Phone Texting Ok: $textok" ;
$content="From: $name \n Email: $email \n Phone: $Phone \n Texting Ok: $textok \n Subject: $subject \n Message: $message " ;
$recipient = "EmiliosNewsletter@gmail.com";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $content, $mailheader) or die("Error!");
mail($recipient, "Volunteer Submission", $content, $mailheader) or die("Error!");
echo "Email sent!";
?>

0 comments on commit 2466bd1

Please sign in to comment.