+ 1

How to insert data to my database

I have created a user registration page, but I am not able to save the username and password to my database, it should be like when you enter the username and password & click submit then it must be save in my database, but I am not getting the right code. Please help me.

3rd May 2018, 9:17 AM
Shubham Gupta
Shubham Gupta - avatar
2 Answers
+ 1
the form should go to a php page On that page: $mysql = new mysqli(host, username, password, db); $insert = "INSERT INTO `users` SET `username` = '".$_POST['username']."', `password` = '".$_POST['password']."'"; $mysql->query($insert); $id = $mysql->insert_id; // if you need it change field names etc as you need to.
3rd May 2018, 9:51 AM
Adam
Adam - avatar
3rd May 2018, 12:51 PM
Toni Isotalo
Toni Isotalo - avatar