PHP does not insert in tables

I’m having trouble getting a practice signup form to submit data to my database …





In addition to Ugur’s answer, you are mismatching mysqli commands and mysql commands. Here’s how to do this in an object oriented fashion:

// create mysqli database object
$mysqli = new mysqli_connect("localhost","username","password","database");
// store your query in a variable. question marks are filled by variables
$sql = "INSERT INTO table_name ('username','password') VALUES (?,?)";
// prepare command uses $sql variable as query
$stmt = mysqli->prepare($sql);
// "ss" means your 2 variables are strings, then you pass your two variables.
// execute does as it seems, executes the query.
// then print your success message here.

Using prepared statements removes the need to sanitize user input, as harmful input is not substituted into the query directly. For more reading:

There are some good tips for using prepared statements in many different scenarios, as well as towards the bottom, there is an explanation on how prepared statements prevent SQL injection.

Hello, buddy!稿源:Hello, buddy! (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 后端存储 » PHP does not insert in tables

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录