Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate SQL injection #6

Open
lucthienphong1120 opened this issue Dec 18, 2022 · 0 comments
Open

Validate SQL injection #6

lucthienphong1120 opened this issue Dec 18, 2022 · 0 comments

Comments

@lucthienphong1120
Copy link
Owner

Validate SQL injection by Data Type Validation

$query="select * from users where id=".$_GET['id'];
$rs=mysqli_query($db,$query);

Fix SQL injection by Using Prepared Statements

$q = "%".$_GET['q']."%";
$query="select * from toys where name like ? or description like ?";
$stmt = mysqli_prepare($db, $query);
mysqli_stmt_bind_param($stmt, 'ss', $q, $q);
mysqli_stmt_execute($stmt);
$rs=mysqli_stmt_get_result($stmt);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant