Created
October 5, 2023 09:55
neocities forms
This file contains hidden or 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
Neocities is a web hosting service that allows users to create and host their own websites. While Neocities provides the basic infrastructure for creating and hosting websites, it does not offer built-in form-handling capabilities like some other web hosting services or content management systems (CMS). However, you can implement forms on your Neocities-hosted website by using HTML and JavaScript. | |
Here's a basic example of how you can create a simple contact form on your Neocities website: | |
1. **Create the HTML Form**: | |
```html | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Contact Us</title> | |
</head> | |
<body> | |
<h1>Contact Us</h1> | |
<form id="contact-form"> | |
<label for="name">Name:</label> | |
<input type="text" id="name" name="name" required><br> | |
<label for="email">Email:</label> | |
<input type="email" id="email" name="email" required><br> | |
<label for="message">Message:</label><br> | |
<textarea id="message" name="message" rows="4" cols="50" required></textarea><br> | |
<input type="submit" value="Submit"> | |
</form> | |
</body> | |
</html> | |
``` | |
2. **Add JavaScript for Form Submission**: | |
You can use JavaScript to handle the form submission. Here's a simple example using JavaScript and the Fetch API to send form data to a server: | |
```html | |
<script> | |
document.getElementById('contact-form').addEventListener('submit', function (e) { | |
e.preventDefault(); | |
const formData = new FormData(this); | |
fetch('/your-server-endpoint', { | |
method: 'POST', | |
body: formData | |
}) | |
.then(response => { | |
if (response.ok) { | |
// Handle success (e.g., show a success message) | |
} else { | |
// Handle error (e.g., display an error message) | |
} | |
}) | |
.catch(error => { | |
// Handle network error | |
}); | |
}); | |
</script> | |
``` | |
Replace `'/your-server-endpoint'` with the actual URL where you want to handle the form data on your server. | |
3. **Set Up Server-Side Processing**: | |
On your server, you will need to create a script (e.g., in PHP, Python, Node.js, etc.) to handle the form data sent from the HTML form. This script should process the data and, if necessary, send email notifications or perform other actions based on the form submission. | |
Keep in mind that handling form submissions on your own server may require some server-side scripting knowledge. Additionally, you should implement security measures to prevent spam and protect sensitive data. | |
Remember to replace the placeholders in the code with your actual form fields, server endpoint, and any other relevant details specific to your website and requirements. |
To create a contact form for your Neocities website using Fabform
Here's how you can set it up:
-
Set Up Your Form on Fabform:
- Visit Fabform.io and create an account if you haven't already.
- Once logged in, create a new form.
- After creating your form, Fabform will provide you with a unique form submission URL.
-
Create the HTML Form:
-
In your Neocities site's HTML file, add the following form code:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Contact Us</title> </head> <body> <h1>Contact Us</h1> <form action="https://fabform.io/f/your-form-id" method="POST"> <label for="name">Name:</label><br> <input type="text" id="name" name="name" required><br><br> <label for="email">Email:</label><br> <input type="email" id="email" name="email" required><br><br> <label for="message">Message:</label><br> <textarea id="message" name="message" required></textarea><br><br> <button type="submit">Submit</button> </form> </body> </html>
Note: Replace
"https://fabform.io/f/your-form-id"
in theaction
attribute with the actual URL provided by Fabform for your form.
-
-
Publish Your Form:
- Upload the HTML file to your Neocities site.
- Ensure that the form is accessible and functions as intended.
With this setup, when a user submits the form, the data will be sent directly to Fabform's servers for processing, all without the need for any JavaScript on your part. Fabform allows you to:
- Receive email notifications for each submission.
- View submissions in your dashboard.
- Integrate with third-party tools like Slack, Google Sheets, or Zapier to automate workflows.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That was very helpful to add neocities forms