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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • 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.