If i use jquery validation values are not storing in database

<!doctype html>
<html lang="en">
        <meta charset="utf-8">
        <title> School Registration Form </title>
1 Like

Does the PHP script get executed? If it doesn’t insert, what error message do you get?

I see the problem, it looks like you haven’t actually started the Javascript part yet. You just place the Javascript in the page, but it isn’t being executed because you haven’t started it with <script type="text/javascript"> and </script>. Other than that, don’t use the deprecated mysql_* functions. If this is a school assignment, ask your teacher to each you something more up-to-date like mysqli_* or PDO. Also, I don’t see register3.php yet. Is it at the bottom of the page?

I think the OP posted the code of the form and the code of register3.php together, so the PHP code isn’t actually part of the form.

Ok, so all 3 files are together? Alright, well I’m going to test these to make sure they aren’t inserting empty fields first.

1st is html page. 2nd is script3.js 3rd is register3.php. u remove validation. it ll store in db

values are storing in db if i dont use validation

Ok, I see where the problem is. You are getting undifined index for all of your $_POST values. You appended a 1 after every $_POST value. Your fields on the HTML part has no $_POST value ending in 1.

Also, you might want to update your snippet. There are no validations via PHP and you are very prone to SQL Injections. You need to ask the teacher if you can bring the snippet up-to-date. You are inserting raw value into the database. So if I type something like


It will literally delete the whole table without you even knowing it. That is a really bad idea.

1 Like

@sunayana_patil, it’s been posted around here before, but this XKCD cartoon seems appropriate at this point to illustrate the consequences of not validating data as it’s entered into a database.


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