A
A
Artem00712017-01-12 14:31:37
PHP
Artem0071, 2017-01-12 14:31:37

How to save the text in the database and then display it?

Good afternoon!
I'm confused.. How to save the text in the database and then display it? And at the same time, so that nothing is deleted in the database and everything is displayed beautifully.
I want to create a Blog, in which a person enters some text, and at the same time can use tags.
In var_damp($_POST['text']) I get:
$_POST['text'] =>bold text иitalic
If I do htmlspecialchars($_POST['text']), then var_damp outputs the following

$_POST['text'] => <b>жирный текст</b> и <i>курсив</i>

In general, how would it be more correct to store this in the database and then display it on the page? And at the same time, so that no one in the database deletes or changes anything, and so that no unexpected alerts fall out on the client
Thank you in advance!

Answer the question

In order to leave comments, you need to log in

6 answer(s)
A
Alexander, 2017-01-12
@Artem0071

If you use PDO - keep it as it is, without any changes, if you write queries yourself, then you need to escape the quotes.
var_damp has nothing to do with the database, don't look at it.

D
d-stream, 2017-01-12
@d-stream

As one of the options, store the source text with tags like BB codes in the database, and where it is necessary to display html, parse these codes and replace them with the corresponding html constructs
. comments - source BB codes (so that when a user edits a message, they do not have to do a reverse transformation.
You can peep the implementations in the source codes of forum engines like phpBB, Invision Power Board, etc.

T
ThunderCat, 2017-01-12
@ThunderCat

With a normal insertion (for example, via PDO), store as given by the user, while outputting, you can cut "undesirable" tags, symbols, and so on.
In general: the correct approach is to store as is, output by filtering.

A
Alexander X, 2017-07-04
@admv

In short, then:
1. with the so-called. states, you can work with legal entities in any way you like, provided that the relationship is correctly formalized (if you are an individual entrepreneur, then either GPA or part-time employment under the Labor Code, if you are an individual entrepreneur or LLC, then the usual service agreement between two legal entities)
1.2. ... but you will pay different taxes:
- according to the GPA - do not forget to declare and pay personal income tax 13% of what you received,
- according to the Labor Code - do not forget that the CUSTOMER must pay for you to funds (aka UST) and the same personal income tax (in total - 50% of what you rely on) ... and if personal income tax is paid this way and that, but UST - in this case it goes from above. And not from your pocket. Well, you understand how "profitable" it is (although, in some specific cases, it happens that it is really more profitable, but these are very specific cases).
- if you are an individual entrepreneur on USN-6, then pay the state 6% of what you received.
- if you are an LLC on the simplified tax system-6 - pay 6% on the simplified tax system and the same 50% upon withdrawal (ESSN + personal income tax).
2. It affects the price tag (from the position of the customer) very indirectly:
- firstly, psychologically (if you are an LLC, then you are a "fiirma", if an individual entrepreneur, then at least just a professional, and if a physicist, then understand who the hell is).
- secondly, with the so-called. additional costs (we are talking mainly about the option "according to TC")
- thirdly, the costs of GPA (and in the foreseeable future - and under contracts with individual entrepreneurs) do not reduce the taxable base (well, formally, they should reduce, but very often they raise questions from the Federal Tax Service, and therefore are not held in high esteem by white offices) . In other words, if you are an LLC, it will be easier to negotiate ... if FL is harder, and you will have to bargain (and either there will be fewer contacts, or they will be at lower price tags).
TOTAL: my recommendation is to open an individual entrepreneur, and the trick is in the bag ... costs - about 5K around, according to the USN-6 system, accounting can be done without problems in all kinds of SaaS, well, or outsourced for 3..7K per quarter .. Once I got confused - but then I can conclude an agreement without problems, and accept / send money by bank transfer ... And the experience of registering and staying in the status of an official legal entity is a useful thing (moreover, the main value is not in the skill itself, but in de- demonization of the very fact of registration, communication with the IFTS, etc.).

S
Sergey, 2017-07-04
@begemot_sun

The price tag rises not from the presence / absence of individual entrepreneurs, but from the presence / absence of a flow of customers.
If you are a very busy person, raise your prices.
If not, then the promotion will not help you.
In the matter of pricing, you need to look for a middle ground, it's better to work 2 hours for 10k than 10 hours for 20k
:) without IP you limit the circle of your clients, with IP you have a larger circle of potential buyers of your services. Yes, and no one will forbid you to work "in the black", let them first prove this work and receive money for services.

S
Sanes, 2017-07-04
@Sanes

IP won't do much. But if LLC , then this is another matter. Only first you need to find orders for LLC , and then place them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question