Skip to content

Commit

Permalink
contact but unfinished
Browse files Browse the repository at this point in the history
  • Loading branch information
vliu12 committed Oct 14, 2024
2 parents 9dfa29a + 83131ff commit 690e9ad
Show file tree
Hide file tree
Showing 10 changed files with 257 additions and 18 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is Music in the Neighbourhood's Website! Thanks for visiting.
56 changes: 56 additions & 0 deletions contact.html
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">&#9776;</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>
28 changes: 28 additions & 0 deletions contact.js
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));
});

13 changes: 7 additions & 6 deletions donate.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
<label for="checkbox_toggle" class="hamburger">&#9776;</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>
</div>
<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>
Expand Down
1 change: 1 addition & 0 deletions events.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<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>
Expand Down
13 changes: 7 additions & 6 deletions gallery.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
<label for="checkbox_toggle" class="hamburger">&#9776;</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>
</div>
<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>
Expand Down
13 changes: 7 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
<label for="checkbox_toggle" class="hamburger">&#9776;</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>
</div>
<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>
Expand Down
12 changes: 12 additions & 0 deletions package.json
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"
}
90 changes: 90 additions & 0 deletions resources/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -318,3 +318,93 @@ padding-bottom: 100px;
text-align: center;
padding: 5px;
}


.contact-form {
align-items: center;
}


.form-container {
background-color: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
max-width: 400px;
width: 100%;
text-align: center;
}

.form-wrapper {
height: 100vh; /* Full viewport height for centering */
display: flex;
justify-content: center;
align-items: center;
background-color: #f2f2f2;
}

/* Form Heading */
.form-container h1 {
font-size: 24px;
margin-bottom: 20px;
color: #333;
}

/* Label styling */
label {
display: block;
text-align: left;
margin-bottom: 8px;
font-size: 14px;
color: #555;
}

/* Input field styling */
input[type="text"],
input[type="email"],
textarea {
width: 100%;
padding: 10px;
margin-bottom: 20px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 14px;
box-sizing: border-box;
background-color: #f9f9f9;
}

/* Textarea styling */
textarea {
height: 100px;
resize: none;
}

/* Button styling */
button[type="submit"] {
width: 100%;
padding: 10px;
background-color: #5cb85c;
color: white;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s ease;
}

button[type="submit"]:hover {
background-color: #4cae4c;
}

/* Add some spacing for the form fields */
input, textarea {
margin-bottom: 15px;
}

/* Responsive styling */
@media (max-width: 600px) {
.form-container {
padding: 15px;
max-width: 90%;
}
}
48 changes: 48 additions & 0 deletions server.js
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}`);
});

0 comments on commit 690e9ad

Please sign in to comment.