Jump to content

function logic funcion


abubaker0000

Recommended Posts

function abuf_user_add($name,$password,$email,$isadmin)
{
	global $af_con;
	if((empty($name)) || (empty($password)) || (empty($email)) || empty($isadmin))
	{
		return false; // for check that is not empty
	}
	$n_email  =mysqli_real_escape_string($af_con,strip_tags($email));
	if(!filter_var($n_email,FILTER_VALIDATE_EMAIL))//for make sure that is email
	{
		return false;
	}
	$n_name   =mysqli_real_escape_string($af_con,strip_tags($name));//
	$n_pass   =md5(mysqli_real_escape_string($af_con,strip_tags($password)));// for encrypting password
	$n_isadmin=(int)$isadmin;
	$query=sprintf("insert into `user` valuse (NULL,'%s','%s','%s','%d')",$n_name,$n_pass,$email,$n_isadmin);
	echo $query;
	$qresult=mysqli_query($af_con,$query);
	if(!$qresult)
	{
		return false;
	}
	return true;
}

in this insert function there is a logic error ... how I can fix it ?

Link to comment
https://forums.phpfreaks.com/topic/291266-function-logic-funcion/
Share on other sites

It's not just the MD5. For some strange reason you've decided to actively change the password by throwing all kinds of functions at it before you store it in the database.

 

Using strip_tags() is particularly harmful, because it deletes everything that resembles HTML markup. If the password happens to include a “<”, then strip_tags() will cut off the password from that point. For example, the strong password “]/q<G,.K9A” would become the incredibly weak password “]/q”. That's obviously a big problem.

 

Do not silently alter the user password! When I choose a password, I want this password, not a shorter password or a different password chosen by you. If you don't know how to protect yourself from SQL injections and cross-site scripting, then ask. But don't just randomly apply all kinds of functions in the hopes that this will somehow make you secure. Programming doesn't work like this.

 

You need to learn about

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.