Jump to content

[SOLVED] How to strip characters


peranha

Recommended Posts

How do you strip special characters from a username, password, other input.

 

here is the code that I currently have, but it doesnt strip ">

$username = empty($_POST['username']) ? die ("<b class=red>Enter A User Name</b>") : mysql_real_escape_string(strip_tags(htmlspecialchars($_POST['username'])));

 

You can register with ">name, and it will let you just fine.

Link to comment
https://forums.phpfreaks.com/topic/94052-solved-how-to-strip-characters/
Share on other sites

yes, i know what > is not a tag, but i was woundering how to get rid of a single instance, and how to get rid of " as well.

 

I tried your code, but it doesnt seem to work.

 

// Tags to strip for input.
$tags = array("<", ">");

// username to strip tags from.
$username = str_replace($tags, "", $_POST['username'] );

 

Here is what I input "> asdaf

 

Here is what I get from the output.

 

Here is the username you requested : \"> asdaf

 

Not sure where the \ is coming from either.

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.