Link to home
Start Free TrialLog in
Avatar of Daniel Mina
Daniel Mina

asked on

Creating a form to insert data into a database

Hi experts,
First of all, I'm not a web developer.
I have a web-host account, a SQL database and a domain name. I need to do the following Max by tomorrow :)
- I need a very simple form consists of 4 or 5 fields to insert data.
- A save button to save data in database.
Or any other method to do the same through my webpage.

Thanks in advance,
Daniel Mina
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Well a form is simple https://www.w3schools.com/html/html_forms.asp
<form method="'post" acttion="somepage">
  First name:<br>
  <input type="text" name="firstname"><br>
  Last name:<br>
  <input type="text" name="lastname">
<button type="submit">Submit</button>
</form>

Open in new window

Just add more fields as needed.

The hard part is accepting data. You need to use a serverside language like .NET, PHP, Node etc.  Which language are you using and which sql database? MySQl, MSSQL or something else?

While the form code is easy, you should add other feature to prevent spam such as a captcha or honeypot. I found the honypot to work the best for me.

https://en.wikipedia.org/wiki/CAPTCHA
https://en.wikipedia.org/wiki/Honeypot_(computing)
Avatar of Daniel Mina
Daniel Mina

ASKER

Hi Scott,
Thanks a lot for your response, well I don't use any web development language as I mentioned before that I'm not a web developer but I have a very good experience in database. I use MS SQL server. I have a table for data to be inserted in but I need to know how.
You said, "First of all, I'm not a web developer."

Then best to use an existing CMS system like WordPress.

There is no way to answer your question without delving deeply into Web development... especially if you're writing custom code, because what you're asking is to re-develop a CMS like WordPress from scratch.

Form correctness will likely require session management.

Writing to your database will mean you must learn rudimentary HTML + PHP + MariaDB/MySQL.

What you're asking may seem simple + it's far more complex than you might imagine.

If you really think you must reinvent the wheel (WordPress or similar), then you'll begin by...

Answering all Scott's questions, which will start the process of evolving you into a Web Developer.
ASKER CERTIFIED SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Daniel,

Inserting data into a Database is pretty straight forward but you will need some development skills.

Basically there are 2 parts to your requirements. The first part is what's called the Client Side code. This is the front-facing part of your application - the bit that the user sees when they visit your site, and in your case, this would be a simple HTML form. You start with a <form> tag and set the method (how the data will be send to the server) and the action (where on the server it will be sent). You include form fields to allow your user to input data, and you add a Submit button. Scott's already shown you a basic setup for an HTML form.

The second part of your requirement is where your development skills come into play. This is called the Server Side code. This is the code that is responsible for taking the data from the form and inserting it into your database. To do this you will need to create a script using a server-side scripting language. There are several languages available to do this, such as PHP, C#, NodeJS etc., and which one you choose will depend on how your server is set up. You haven't given us that information so we can't give you a specific answer. Whichever one you choose though will effectively do the same thing - it will create a connection to your database, it will check the validity of the submitted data, and it will run a database query (INSERT INTO in your case). It will usually then generate a response that you can display to the user ("Data Updated OK" etc.)

If you let us know what server-side language you have available and exactly what Database server you're running (you say SQL, but is this MS SQL or MySQL??), we can give you more specific examples of what you need to do.
Thanks a lot guys for your detailed responses.

Hi Chris,
My web-host supports .net and database is MS-SQL.
OK. Then your server-side code is probably going to be done using ASP.NET, and if you're not a developer, then I would suggest that you're going to find this tricky - particularly if you have a deadline of today.

I would recommend that you edit your question and add the ASP.NET / C# topics to it as that will attract Experts with the suitable level of knowledge.
Done, Thanks a lot Chris.
I asked one of our .NET Experts try and assist here.
Hi Daniel,

If your web host supports .net core (Most probably they should) then you can start with https://orchardproject.net/. I think that is the only Open Source CMS I see you can start using very quickly and get results. You don't need to be a developer but you will have to follow the instructions step by step, to set it up.

Also, if it is just a form and you need it for a temporary period, you can try Microsoft Forms PRO https://formspro.microsoft.com/en-us/, one month trial is free.

If that does not fit the bill and you are willing to shell out money then there are couple of commercial solutions as well, for example, http://www.composite.net/ but even those will require you to follow some steps to complete the setup.

PS: I am not mentioning classic Orchard, Umbraco, Telligent, BlogEngine etc. as they are bit more complex to setup but still are really great Open Source solutions.

PPS: Actually, if it is just 1 form with 5 fields, you could easily get someone on Fiver or Upwork to complete it for you at a nominal cost.

Regards,
Chinmay.
Thanks a lot guys, your responses were very helpful for me. I got a friend who managed this task as per your recommendations.