Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

htmlentities()

Options
  • 29-01-2007 3:12pm
    #1
    Registered Users 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 Posts: 6,511 ✭✭✭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 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 Posts: 6,511 ✭✭✭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