-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
257 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is Music in the Neighbourhood's Website! Thanks for visiting. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<link href="./resources/css/index.css" type="text/css" rel="stylesheet"> | ||
|
||
<title>Donate</title> | ||
</head> | ||
<body> | ||
|
||
<nav class="navbar"> | ||
<!-- LOGO --> | ||
<div class="logo">Music in the Neighbourhood</div> | ||
|
||
<!--NAVIGATION MENU--> | ||
<ul class="nav-links"> | ||
|
||
<input type="checkbox" id="checkbox_toggle" /> | ||
<label for="checkbox_toggle" class="hamburger">☰</label> | ||
|
||
<!-- NAVIGATION MENUS --> | ||
<div class="menu"> | ||
<li><a href="./index.html">Home</a></li> | ||
<li><a href="./events.html">Events</a></li> | ||
<li><a href="./gallery.html">Gallery</a></li> | ||
<li><a href="./donate.html">Donate</a></li> | ||
<li><a href="./contact.html">Contact Us</a></li> | ||
</div> | ||
|
||
</ul> | ||
</nav> | ||
|
||
|
||
<h1>Contact Us</h1> | ||
|
||
<div class="form-wrapper"> | ||
<div class="form-container"> | ||
|
||
<form id="contact-form" action="/send-email" method="POST"> | ||
<label for="name">Your Name:</label><br> | ||
<input type="text" id="name" name="name" required><br><br> | ||
|
||
<label for="email">Your Email:</label><br> | ||
<input type="email" id="email" name="email" required><br><br> | ||
|
||
<label for="message">Your Message:</label><br> | ||
<textarea id="message" name="message" required></textarea><br><br> | ||
|
||
<button type="submit">Send Message</button> | ||
</form> | ||
</div> | ||
</div> | ||
|
||
<script src="contact.js"></script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
document.getElementById('contact-form').addEventListener('submit', function(event) { | ||
event.preventDefault(); // Prevent the form from submitting the traditional way | ||
|
||
// Get the values from the form fields | ||
const name = document.getElementById('name').value; | ||
const email = document.getElementById('email').value; | ||
const message = document.getElementById('message').value; | ||
|
||
// Create a POST request to the backend | ||
fetch('/send-email', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({ name, email, message }) | ||
}) | ||
.then(response => response.json()) | ||
.then(data => { | ||
if (data.success) { | ||
alert('Email sent successfully!'); | ||
document.getElementById('contact-form').reset(); | ||
} else { | ||
alert('Failed to send email. Please try again.'); | ||
} | ||
}) | ||
.catch(error => console.error('Error:', error)); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "musicintheneighbourhood", | ||
"version": "1.0.0", | ||
"description": "Website for MITN", | ||
"main": "contact.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"start": "node server.js" | ||
}, | ||
"author": "Victoria Liu", | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const express = require('express'); | ||
const bodyParser = require('body-parser'); | ||
const nodemailer = require('nodemailer'); | ||
const app = express(); | ||
const PORT = process.env.PORT || 3000; | ||
|
||
// Middleware | ||
app.use(bodyParser.urlencoded({ extended: false })); | ||
|
||
// Serve static files (HTML and CSS) from the root directory | ||
app.use(express.static(__dirname)); // __dirname points to the current directory | ||
|
||
// Route to send email | ||
app.post('/send-email', (req, res) => { | ||
const { name, email, message } = req.body; | ||
|
||
// Create a transporter object | ||
const transporter = nodemailer.createTransport({ | ||
service: 'gmail', // e.g. 'gmail', 'yahoo', etc. | ||
auth: { | ||
user: 'musicintheneighbourhood@gmail.com', // your email address | ||
pass: 'Delta2006!', // your email password or app password | ||
}, | ||
}); | ||
|
||
// Email options | ||
const mailOptions = { | ||
from: email, | ||
to: 'musicintheneighbourhood@gmail.com', // destination email address | ||
subject: `Message from ${name}`, | ||
text: message, | ||
}; | ||
|
||
// Send the email | ||
transporter.sendMail(mailOptions, (error, info) => { | ||
if (error) { | ||
console.log('Error: ', error); | ||
return res.status(500).send('Error sending email'); | ||
} | ||
console.log('Email sent: ' + info.response); | ||
res.status(200).send('Email sent successfully'); | ||
}); | ||
}); | ||
|
||
// Start the server | ||
app.listen(PORT, () => { | ||
console.log(`Server is running on http://localhost:${PORT}`); | ||
}); |