Form data fetch problem

(https://imwashimul.rf.gd/)

I used node.js and connected with SQL database, but when I submitted the form it continuously error to saving form

 const response = await fetch("https://imwashimul.rf.gd/submit-form", { (Failed to load resource: the server responded with a status of 404 ()
        console.error("Error saving form-data"); (Error saving form data)
HTML form - 
<form action="/submit-form" method="post" style="font-size: 12px;">
server.js
app.post('/submit-form', (req, res) => {
  const formData = req.body;
  const sql = 'INSERT INTO feedbackform (name, email, contactNumber, feedbackText, createdAt) VALUES (?, ?, ?, ?, NOW())';

  connection.query(sql, [formData.name, formData.email, formData.contactNumber, formData.feedbackText], (err, result) => {
    if (err) {
      console.error('Error saving form data:', err); // Log the actual error message
      res.status(500).send('Internal Server Error');
    } else {
      console.log('Form data saved successfully');
      res.status(200).send('Form data saved successfully');
    }
  });
});

Error Message

script.js:31 Error saving Form data
(anonymous) @ script.js:31

Other Information

please help me, I would be grateful.

This hosting only supports PHP as the backend language, how are you even using node.js?

4 Likes

already no web is running, except the form, data

already my web is running, except the form, data

You did not answer my question.

1 Like

So I can not do with node.js

You cannot use Node.js on Infinityfree, unsure where you are even hosting it.

6 Likes

You see my domain, I customized my site frontend using - js, jquery, and designs for bootstrap,
for backend inlocalhost is used , node.js, and alos deployed this mean just uploaded on the infinity directory, however i noticed that, node.js commands are not working, thats, why I asked.

I’m not gonna repeat it again: hosting Node.js apps is not a thing on free hosting. You can consider writing your backend in PHP instead, or use a service like Replit to host your Node.js app, but take note that MySQL remote access is not available on free hosting:

5 Likes

thank you for your kind, response, Can you please suggest to me any provide who will be the best fit for - node.js, core-js, and Mongodb? ( as i want to develop my site only using, core-js and node.js and for database mongodb) thank you in advance.

I don’t think there is a hosting provider which can provide all these but you may have better time paying for a cheap VPS and setting things up on your own.

5 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.