In bestece-projects.blogspot.com site you can get the best easy and creative Electrical & Computer Engineering project ideas and tutorials on how to make them.

Website Form data not storing in database


Common mistakes while storing data in a database (table) from a website form

While working on my website project I’ve faced some problems. And recently some of my viewers are also facing those same problems. So I’ve decided to write about some of these problems so it’ll be easier for others to solve when they face these problems.

"Why are my data not storing in the database? I've written everything correctly."



One of the common problems students face while working for the first time with PHP is inserting values into a table in the database from the website. Like - in registration process student need to save the data in a table in the database. Even though the website is connected properly and the query seems to be alright, still the data are not stored.


If you face the same problem you need to check some specific parts of the code. So here’s the way to solve this problem.

Step-1:  First you need to check if the website is connecting with your database or not. Here's a sample code. Save this in the htdocs folder in the xampp folder. Then write "localhost/your-filename.php" .If you see this message it's connected correctly.



Step-2: Then if it’s checked then go back to your form (registration or any form you are checking). See if you’ve written the method=” POST”.



Step-3: If this is okay too, then next you need to check all the form input names and see if the input names are the same as your table’s column name or not. I’m talking about the name, not the placeholder. You can write anything in placeholder but the input name should be the same as the column name.



Step-4: Next check the button name & type. You can write any name but type has to be “submit”.

Step-5: Now if all this is correct then the error is in PHP code. First check is there is any condition for button pressing. If there is then check if the button name is same or not.



Step-6: Then if all of these are correct you need to check the query. Check if the column names are written correctly or not, if table name is correct and the commas and semicolon after query. If you use single quotation beside table name, it shows error sometimes. So I suggest you either don’t use them or use this ` ` instead.



Step-7: At last check if you have forgotten to close any brackets or tags.

That’s it. If all these are correct your problem will be solved. You just need to check the code clearly and find the problem.



Website Form data not storing in database Website Form data not storing in database Reviewed by Sanzida Mou on March 10, 2019 Rating: 5

No comments:

Powered by Blogger.