Jump to content

SQL Injections...


DeathStar

Recommended Posts

It's important to check if you have magic_quotes enabled before escaping- you dont want to escape your data twice...

 

<?php

$safe_username = sql_quote($_POST['user']);
$safe_password = sql_quote($_POST['pass']);

function sql_quote($str)
{
if(get_magic_quotes_gpc())
	$str = stripslashes($str);
return mysql_real_escape_string($str);
}

?>

 

 

Orio.

Link to comment
https://forums.phpfreaks.com/topic/43818-sql-injections/#findComment-212801
Share on other sites

another good idea is to have a white list so if you are specifically looking for a username, access your database, grab all your usernames add them into an array and then check the input with the array and if they dont match you can use the location function to redirect them to another page without their input affecting your database

Link to comment
https://forums.phpfreaks.com/topic/43818-sql-injections/#findComment-212806
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.