Mário Souto Mário Souto - 1 year ago 41
SQL Question

Form dosn't save data into mySQL tables

I'm very new to mySQL, javascript and php. I have a form in my website to register new users into it. Its connected to a users table in my mySQL where it saves the users data.

The thing is I cant apply the javascript constraints to the field forms unless I have

, it will just connect to my php page no matter what and save the data into my table.

But if i use the
it will apply the constraints but when i fill it correctly and click register it wont save anything, just creates an empty user in mysql table.

How can I solve this?

var constraints = {
email: {
email: true,
presence: true,
Telefone: {
format: {
pattern: "[+0-9]+",
message: "apenas pode conter números [0-9]"
pwd: {
presence: true,
length: {
minimum: 5
cpwd: {
presence: true,
equality: {
attribute: "pwd",
message: "as passwords não coincidem"






var errors = validate($("#validationForm"), constraints);

if (errors) {
for (var key in errors) {
$("#error").append(errors[key] + "<br />");
$("#" + key).css("border","1px red solid");
}else {
// $("#submited").html("Form Submited");

// redirect to php


Answer Source

That's because you are manually redirecting to your PHP page.

Instead of this line:


You should rather