I want to register script with sql injection protection.
Printable View
I want to register script with sql injection protection.
PHP Code:<?php
$username = trim($_POST['username']);
$password = trim($_POST['password']);
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
$db_selected = mysql_select_db('foo', $link);
if (!$db_selected) {
die ('Can\'t use foo : ' . mysql_error());
}
$sql = sprintf( "INSERT INTO users(username,password) VALUES('%s','%s')", mysql_real_escape_string($username), mysql_real_escape_string(md5($password)));
$res = mysql_query($sql, $link);
mysql_close($link);
Hmm i think he ment one that is for MSSQL and not for MySql and even that Mysql is old use MySql(I)