Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

htmlentities()

  • 29-01-2007 03:12PM
    #1
    Registered Users, Registered Users 2 Posts: 673 ✭✭✭


    Hi,

    I have been told to use the php function htmlentities() on my site where people can input text in a textfield for security reasons. I have the code as follows but it doesnt seem to be doing anything:

    $my_league_name = $_POST;
    $league_name = htmlentities($my_league_name);

    if i enter $my_league_name as <h1>hello</h1> $league_name is still echoing as <h1>hello</h1>. Should this not be replacing the html tags?

    Thanks


Comments

  • Registered Users, Registered Users 2 Posts: 6,652 ✭✭✭daymobrew


    Maybe the browser is converting the items back to look like HTML.
    Write the returned string to a text file and see what it looks like.


  • Registered Users, Registered Users 2 Posts: 673 ✭✭✭Bananna man


    daymobrew wrote:
    Maybe the browser is converting the items back to look like HTML.
    Write the returned string to a text file and see what it looks like.

    Thanks, thats what was going on. When i view the info in my database its being stored with the html converted.

    Are my scripts still open to people trying to redefine my variables if they try inputting new variables in the textfields?


  • Registered Users, Registered Users 2 Posts: 6,652 ✭✭✭daymobrew


    Are my scripts still open to people trying to redefine my variables if they try inputting new variables in the textfields?
    I don't understand your question.

    If possible, you should do a regular expression check on the entered data, to ensure that it matches the format you expect e.g. for an age request, ensure that you get reasonable numbers.


Advertisement