Link to home
Start Free TrialLog in
Avatar of encodeme
encodemeFlag for Portugal

asked on

Clean up registration and login names etc before inputting in mysql

Hi,
I am trying to clean up my html form inputs before they hit mysql.
Is this possible as I've shown below? (It's not currently working?)
If it will work have I missed anything?
Thanks

$username=  sanitise($_POST['username']);

Open in new window


function sanitise($string) {
  $string = trim($string);
  $string = htmlentities($string);
  $string = strip_tags($string);
  $string = mysqli_real_escape_string($string);
  
  return $string;
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of encodeme

ASKER

H'm I didn't know those functions existed.

I appreciate the code tweaks... never thought of doing it inline.

thanks