Welcome Guest, Not a member yet? Register   Sign In
Two things: HTML entities and Undefined variables
#3

[eluser]Fabdrol[/eluser]
I'm not sure if I get your problem, but if I understant correctly it's the following:

1. User creates an entry with a title, body, maybe more
2. To be complient entities must be encoded when viewed in the browser

Data in form entries doesn't need to be encoded to be complient with your doctype. So, what I would do is save the data 'raw' in the database (e.g., without encoding the entities). That way, you can always be sure that the entry is the way the author intended it.
Then, when somebody views the data, you encode it in the view (or in route to the view). Example:
Code:
<h1>&lt;?= htmlspecialchars($title) ?&gt;</h1>
<p>
  &lt;?= htmlspecialchars($body) ?&gt;
</p>

When a user edits data, you don't encode it, but put it in the edit form in it's "raw" format. That way, your data remains true and the encoding should be no problem.


Messages In This Thread
Two things: HTML entities and Undefined variables - by El Forum - 01-25-2011, 06:56 PM
Two things: HTML entities and Undefined variables - by El Forum - 01-25-2011, 07:02 PM
Two things: HTML entities and Undefined variables - by El Forum - 01-25-2011, 07:06 PM
Two things: HTML entities and Undefined variables - by El Forum - 01-25-2011, 07:11 PM
Two things: HTML entities and Undefined variables - by El Forum - 01-25-2011, 07:13 PM
Two things: HTML entities and Undefined variables - by El Forum - 01-25-2011, 07:23 PM
Two things: HTML entities and Undefined variables - by El Forum - 01-25-2011, 07:36 PM
Two things: HTML entities and Undefined variables - by El Forum - 01-25-2011, 07:42 PM
Two things: HTML entities and Undefined variables - by El Forum - 01-25-2011, 07:59 PM



Theme © iAndrew 2016 - Forum software by © MyBB