Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End how to make variable for html code

  • This topic is empty.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #36676
    ahmed18
    Participant

    Hey guys

    I make this

    
    
    echo $val ;

    ?>

    $val will display HTML code by user like this code

    val

    but image not appear and display this

    http://localhost/wp/%5C%22http://localhost/val.jpg%5C%22
    #96769
    bungle
    Member

    I would guess that the user HTML code is not being escaped and unescaped correctly when it is being stored. Are you storing it in a database and if so are you handing the strings correctly with addslashes() or mysql_real_escape_string() before storing and then unescaping them afterwards before echoing them out? Or are you sending them as a get variable and then not using urldecode()?

    It looks like a combination of both has happened – i.e. that result looks like it has first been escaped and then url encoded

    #96770
    ahmed18
    Participant

    No I don’t use database , I am getting HTML code from textarea content will user put

    #96773
    bungle
    Member

    so the user is posting it with a form? what’s the rest of your code?

    #96775
    ahmed18
    Participant

    I want only make variable display HTML code correctly

    #96785
    bungle
    Member

    sorry but you are not providing enough information to tell you why that is happening.

    PHP is a pre processing language, your user input must be getting to the php somehow, either by being passed as a GET or POST variable, or by being recalled from a database.

    How is the $var variable being set? and how is it being read to generate your unwanted output?

    Need to see all the code to figure that out, what you have provided isn’t enough.

    #96792
    ahmed18
    Participant

    it is not script , it is options page for wp theme

    and i make textarea for putting analytical code and then i use echo to print it in footer

    #96808
    ahmed18
    Participant

    It is the same problem I face
    http://www.wptavern.com/forum/plugins-hacks/1859-theme-options-page-problem-html-text-textarea-inputs.html

    but when I use code for solution give me error

    echo stripslashes(get_settings('content')
    #96818
    ahmed18
    Participant

    thx alot
    I have been used htmlentities() and htmlspecialchare()
    but both of them display HTML code like text not give it’s function for displaying image

    #96834
    ahmed18
    Participant

    thx but still not working

    #96881
    Zeriz
    Member


    $var = "val";

    print $var;
    ?>

    Works fine for me.

    http://writecodeonline.com/php/

Viewing 11 posts - 1 through 11 (of 11 total)
  • The forum ‘Back End’ is closed to new topics and replies.