E
E
elcucuy2018-06-17 20:23:17
PHP
elcucuy, 2018-06-17 20:23:17

Why is the data from the form not being added to the database?

The data is received into the handler, but then it is not added to the database, everything seems to be in order with the connection, since it is possible to pull data from the database with it.

$(function() {
    $('.sign-up-form').submit(function(e) {
      var $form = $(this);
      $.ajax({
        type: $form.attr('method'),
        url: $form.attr('action'),
        data: $form.serialize()
      }).done(function() {
        alert('success');
      }).fail(function() {
        alert('fail');
      });
      e.preventDefault(); 
    });
  });


$login = $_POST['login'];
$name = $_POST['name'];
$lastname = $_POST['email'];
$email = $_POST['email'];
$password = $_POST['password'];

mysql_query("INSERT INTO client(client_login, client_name, client_lastname, client_email, client_password) VALUES (
    '".$login."',
    '".$name."',
    '".$lastname."',
    '".$email."',
    '".$password."',
)", $link);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ruslan., 2018-06-17
@LaRN

It looks like there is an extra comma in the query and a sql error occurs.
Here:
'".$password."',
)", $link);
You don't need a comma before the closing bracket in the values ​​section.
Try this:
'".$password."'
)", $link);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question