Jump to content
php.lv forumi

mysql_real_escape_string


Recommended Posts

Posted

nestrādā a.k.a FF izmet Dont Send ka PHP beidzis strādāt :/

 

$username = strip_tags(stripslashes(mysql_real_escape_string($username)));
$passhash = sha1($pass.'xxx');
$mail = strip_tags(stripslashes(mysql_real_escape_string($mail)));
$country = strip_tags(stripslashes(mysql_real_escape_string($country)));
$city = strip_tags(stripslashes(mysql_real_escape_string($city)));
mysql_query("INSERT INTO party_users (username,pass,email,country,city) VALUES ('".$username."','".$passhash."','".$mail."','".$country."','".$city."')");

Posted

Pag, man pašam arī būtu jāapgūst security... :D Kā būtu šis kods jāpārveido?

 

$username = $_POST['username'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$email = $_POST['email'];

// some code.

$sql = "INSERT INTO `members` (`username`, `password`, `email`) VALUES ('$username', '$password', '$email')";
mysql_query($sql) or die('<strong>' . mysql_errno() . '</strong>: ' . mysql_error());

 

Kā šādi?

 

$username = $_POST['username'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$email = $_POST['email'];

// some code.

$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$email = mysql_real_escape_string($email);

$sql = "INSERT INTO `members` (`username`, `password`, `email`) VALUES ('$username', '$password', '$email')";
mysql_query($sql) or die('<strong>' . mysql_errno() . '</strong>: ' . mysql_error());

Posted

Pag, man pašam arī būtu jāapgūst security... :D Kā būtu šis kods jāpārveido?

 

$username = $_POST['username'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$email = $_POST['email'];

// some code.

$sql = "INSERT INTO `members` (`username`, `password`, `email`) VALUES ('$username', '$password', '$email')";
mysql_query($sql) or die('<strong>' . mysql_errno() . '</strong>: ' . mysql_error());

 

Kā šādi?

 

$username = $_POST['username'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$email = $_POST['email'];

// some code.

$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$email = mysql_real_escape_string($email);

$sql = "INSERT INTO `members` (`username`, `password`, `email`) VALUES ('$username', '$password', '$email')";
mysql_query($sql) or die('<strong>' . mysql_errno() . '</strong>: ' . mysql_error());

 

Bravo! :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...