Insert data into multiple tables using one form

后端 未结 5 758
半阙折子戏
半阙折子戏 2020-12-29 17:47

I am trying to insert data in 2 tables using one form.

This is my form

<
5条回答
  •  一生所求
    2020-12-29 18:17

    You run your queries with the same variable $sql. You should call them differentely like that and call them after.

    $sql="INSERT INTO donator (nume, prenume, numar_telefon) VALUES ('mysql_real_escape_string($_POST[nume])','mysql_real_escape_string($_POST[prenume])','mysql_real_escape_string($_POST[numar])')";
    $sql2="INSERT INTO donatie (suma, data_donatie, IBAN) VALUES ('mysql_real_escape_string($_POST[suma])','mysql_real_escape_string($_POST[data])','mysql_real_escape_string($_POST[iban])')";
    

    Otherwise, you must change your post values by protecting them. Refer here

    Then, you have to switch to new mysql syntax for PHP, like mysqli or PDO. THe mysql syntax you are using is deprecated.

提交回复
热议问题